#include%26lt;stdio.h%26gt;
#include%26lt;conio.h%26gt;
void main()
{
int n,i,f,j;
int s=0;
printf("enter the value of n");
scanf("%d",%26amp;n);
for(i=2;i%26lt;=n;i++)
{
f=0;
for(j=2;j%26lt;i;j++)
{
if(i%j==0)
{
f=1;
}
}
if(f==0)
{
printf("%d\n",j);
s=s+j;
}
}
printf("the sum is %d",s);
getch();
}
What is the turbo c program that display and add all the prime numbers from 1-N.?
It's a small program, and an easy piece of homework. Homework is given to you for a reason - to help you learn. If you rely on other people to do your work, you will learn _nothing_ in the process (other than the ancient art of being a lazy freeloading s.o.b.).
peony
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment