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


Please Help Members By Posting Answers For Below Questions

What is a program flowchart?

698


List the difference between a 'copy constructor' and a 'assignment operator' in C?

737


What do you mean by keywords in c?

752


List a few unconditional control statement in c.

652


What are the different categories of functions in c?

764






What do you mean by dynamic memory allocation in c?

733


What is the heap?

804


Why do we use namespace feature?

679


What are the ways to a null pointer can use in c programming language?

697


What is a built-in function in C?

938


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

1084


What are the uses of a pointer?

770


What is structure pointer in c?

670


5 Write an Algorithm to find the maximum and minimum items in a set of ā€˜nā€™ element.

1685


What is call by value in c?

653