Write a program to print the following series
2 5 11 17 23 31 41 47 59 ...

Answers were Sorted based on User's Feedback



Write a program to print the following series 2 5 11 17 23 31 41 47 59 .....

Answer / riya

2 5 9 13 17 23 31

Is This Answer Correct ?    18 Yes 16 No

Write a program to print the following series 2 5 11 17 23 31 41 47 59 .....

Answer / 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

More C Interview Questions

what is the advantage of software development

1 Answers  


Explain why c is faster than c++?

0 Answers  


Write the program that calculates and prints the average of several integers. Assume that the last value read is sentinel 9999.

0 Answers  


What is #error and use of it?

0 Answers  


AMMONG THE 4 STROAGE CLASSES IN C, WHICH ONE FASTEST?

13 Answers   HCL,






what is the different between if-else and switch statment (other than syntax)

26 Answers   CTS, Oracle, Scorpos,


const char * char * const What is the differnce between the above tow?.

6 Answers   Ramco, TCS,


Which one would you prefer - a macro or a function?

0 Answers  


Explain 'bus error'?

0 Answers  


what is the associativity of bitwise OR operator?

1 Answers  


how to TOGGLE Nth bit of variable in a MACRO

1 Answers   NDS,


What is the process to create increment and decrement stamen in c?

0 Answers  


Categories