Question

1) Write a C program to print the prime numbers from 1 to 100. (A prime integer is any integer that can be divided evenly only by itself and 1)

Requirement: Use an array to take the number from 1 to 100 and another array to take the prime number.

Answer #1

Please follow the code and comments for description :

**CODE :**

/* C program to find all prime numbers from the inputted array
*/

#include<stdio.h>

int main() // driver method

{

int ar[100], i, n, j, counter, res[100], m = 0; //
local variables

for(i = 0; i < 100; i++) // iterate and save the
data

{

ar[i] = (i + 1);

}

printf("The Array is - \n"); // message

for(i = 0; i < 100; i++)

{

printf("\t %d", ar[i]); //
message

}

printf("\n");

printf("\nAll the Prime Numbers in the Array are
-\n"); // message

for(i = 0; i < 100; i++) // iterate to calcualte
the primes

{

counter = 0;

for(j = 2; j < ar[i]; j++)

{

if(ar[i] % j ==
0) // prime number condition

{

counter = 1;

break;

}

}

if(counter == 0) // if true

{

res[m] =
ar[i]; // assign to another array

printf("\t %d",
res[m]); // message

m++; //
increment the count

}

}

printf("\n"); // new line character

return 0;

}

**OUTPUT :**

Hope this is helpful.

Prime Numbers) Write a program to calculate and print a list of
all prime numbers from 1 to 100.
C programming

write a C++ program that display a prime numbers between 1 and
100 number. Plase print the remaining primes by “dots” For gexample
The output should appear like
The prime numbers between 1 and 100 are: 1, 2, 3, 5, 7,
.........

Write a program that finds and prints all of the prime numbers
between 3 and X (X is input from the user). A prime number is a
number such that 1 and itself are the only numbers that evenly
divide it (for example, 3, 5, 7, 11, 13, 17, …).
One way to solve this problem is to use a doubly nested loop (a
loop inside another loop). The outer loop can iterate from 3 to N
while the inner...

PYTHON 3
Write a program that prints the count of all prime numbers
between A and B (inclusive), where A and B are defined as
follows:
A = 21212
B = A + 5000
Just a recap on prime numbers: A prime number is any number,
greater or equal to 2, that is divisible ONLY by 1 and itself. Here
are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and
29.
Rules:
You should first...

1- Write a program to print only the even numbers from 100 to
200
2- Write a program to print the odd numbers from 22 – 99
3- Write a program to calculate howe many even number from 10
to 120
1- Write a program to find only the even numbers for 12
different numbers
2- Write a program to find the odd numbers for 10 different
numbers
3- Write a program to calculate howe many even number and how...

Write the following in C:
2. An integer is said to be prime if it is divisible by only 1
and itself. Write a function called prime() that takes in one
integer number, and returns 1 (true) if the number is prime and 0
(false) otherwise. Write a program to generate six random numbers
between 1 to 100 and calls function prime() on each one to
determine if it is prime or not.

C++
INSTRUCTIONS Problem Specification
: Write a program that reads a group of numbers from the user
and places them in an array of type float. Once the numbers are
stored in the array, the program should average and print the
result. Use pointer notation wherever possible.
Program Output (with Input Shown in Bold):
Enter number: 2 Enter another (y/n)? y
Enter number: 4 Enter another (y/n)? y
Enter number: 6 Enter another (y/n)? y
Enter number: 8 Enter another...

/*
This program should check if the given integer number is
prime.
Reminder, an integer number greater than 1 is prime if
it divisible only by itself and by 1.
In other words a prime number divided by any other natural
number
(besides 1 and itself) will have a non-zero remainder.
Your task:
Write a method called checkPrime(n) that will
take
an integer greater than 1 as an input, and return true
if that integer is prime; otherwise, it should...

A prime number is an integer greater than 1 that is evenly
divisible by only 1 and itself. For example, 2, 3, 5, and 7 are
prime numbers, but 4, 6, 8, and 9 are not. Create a PrimeNumber
application that prompts the user for a number and then displays a
message indicating whether the number is prime or not. Hint: The %
operator can be used to determine if one number is evenly divisible
by another. ( Java programing...

Design a program in Java that displays all of the prime numbers
from 1 through 100. The program should have a loop that calls the
isPrime() function.
11 Prime Numbers List (15 points)
Use CONSTANTS to set the maximum number in the table to
100 and the number of entries per row to
5.
Table of prime numbers from 1 to 100
1 2 3 5 7
11 13 17 19 23
29 31 37 41 43
47 53 59...

ADVERTISEMENT

Get Answers For Free

Most questions answered within 1 hours.

ADVERTISEMENT

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 1 hour ago

asked 2 hours ago

asked 2 hours ago

asked 2 hours ago