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
What is a program flowchart?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
What do you mean by keywords in c?
List a few unconditional control statement in c.
What are the different categories of functions in c?
What do you mean by dynamic memory allocation in c?
What is the heap?
Why do we use namespace feature?
What are the ways to a null pointer can use in c programming language?
What is a built-in function in C?
In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping
What are the uses of a pointer?
What is structure pointer in c?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
What is call by value in c?