Write a program to print all the prime numbers from 1 to 100.
#include <stdio.h>
#include <conio.h>
void main ( )
{
int md, no, co, fl;
clrscr ( );
printf ("\n\n\t\t\t Prime numbers from 1 to 100\n\n");
for ( no = 1; no <= 100; no++ )
{
fl = 0;
for ( co = 2; co < no; co++ )
{
md = no % co;
if ( md == 0 )
{
fl = 1;
break;
}
}
if ( fl == 0 )
printf (" %d ", no);
}
getch ( );
}
Click here to contact us
No comments:
Post a Comment