It's for class.How do you make a C program that displays all prime numbers from 50 to 100?
int isPrime(int n) { int i; for (i=2;i%26lt;n/2;i++) if (n%i==0) return 0; return 1; }
int i; for (i=50; i%26lt;=100; i++) if (isPrime(i)) printf(';%d\n';, i);How do you make a C program that displays all prime numbers from 50 to 100?
include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
main()
{
int isprime;
clrscr();
for (int i=50;i%26lt;=100;i++)
{
isprime=1;
for (int j=2;j%26lt;=i-1;j++)
{
if(i%j==0)
{
isprime=0;
}
}
if(isprime==1)
printf(';%d\n';,i);
}
getche();
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment