C Program to Print Prime Numbers From 1 to n

 

1. C program to print numbers from 1 to n using for loop

In this program, the compiler will ask the user to enter the number to which the user wants to print prime numbers using for loop.

C

Output:

c program to print prime numbers from 1 to n

2. C program to Print Prime Numbers from 1 to n using while loop

In this program, the compiler will ask user to enter the minimum and maximum number from which user wants to print all prime numbers between minimum and maximum using while loop.

C

Output:

c program to print prime numbers from 1 to n

In the above program, we have used while loop instead of for loop. Don’t be afraid program is simple and the logic behind the program is the same.

3. C program to print Prime Numbers between 1 to 100 using for loop

C

Output:

prime number program in c

4. C program to print Prime Numbers between 1 to 100 using While loop

C

Output:

using while loop

5. Program to calculate the sum of prime number from 1 to 100

In this program, the compiler will calculate and print the addition of prime numbers from 1 to 100

C

Output:

prime number program in c

6. Program to calculate the sum of prime number from 1 to n

C

Output:

addition of prime numbers from 1 to n

No comments