Write a program to print all prime numbers from 1 to 300. (Hint: Use nested loops, break and continue statements.)

Improvements:
The work done by the computer is considerably used..if we chuck out all the even numbers..cuz even numbers cannot be prime numbers (except the number 2)

Also, 1 is not a prime number. Instead..it is a Unique Number.



#include<stdio.h>

main()
{

int number, div, ifprime;



for (number=2;number<=300;number++)

{

for (div=2; div<number; div++)

{
if (number%div==0)
{

ifprime=0;
break;
}

ifprime=1;

}

if (ifprime)
{
printf("\n%d", number);

}
}
}




The File can be found at:
Download File

No comments:

Post a Comment

kiss on google ads if you are anonymous because your ip is trackable.thank you.

......from.admin