Write a program to print the following series
2 5 11 17 23 31 41 47 59 ...
Answer Posted / dixit
#include<stdio.h>
int main()
{
int i=0,j=0,c=0,ct=-1,n=0;
scanf("%d",&n);
printf("2 ");
for(i=4;i<100;i++)
{ c=1;
for(j=2;j<=i/2;j++)
{
if(i%j==0) c=0;
}
if(c!=0){ ct++;
if(ct%2==0 && n>1 ) {
printf("%d ",i);
n--;
}
}}
return 0;
}
| Is This Answer Correct ? | 8 Yes | 20 No |
Post New Answer View All Answers
Explain what is the benefit of using #define to declare a constant?
about c language
How can I implement sets or arrays of bits?
Does c have class?
What is structure padding and packing in c?
What does c mean before a date?
What is binary tree in c?
Why is c called c?
What does calloc stand for?
define string ?
Why is extern used in c?
Are c and c++ the same?
What is string constants?
How can I make it pause before closing the program output window?
Why do we use c for the speed of light?