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

when user give a number it multiply with 9 without useing '+' and '*' oprator

4 Answers  


What are preprocessor directives in c?

0 Answers  


what is the difference between <stdio.h> and "stdio.h"

14 Answers   Invendis, Kanbay, Mastek, MathWorks,


What is the difference between %d and %i?

0 Answers  


how to write a bubble sort program without using temporary variable?

1 Answers   Aricent,






What is the use of clrscr?

0 Answers  


What is advantage of pointer in c?

0 Answers  


This is a variation of the call_me function in the previous question:call_me (myvar)int *myvar;{ *myvar += 5; }The correct way to call this function from main() will be a) call_me(myvar) b) call_me(*myvar) c) call_me(&myvar) d) expanded memory

0 Answers  


Explain what is the purpose of "extern" keyword in a function declaration?

0 Answers  


what is the difference between normal variables and pointer variables..............

15 Answers   HP, Infosys, Satyam, Vivekanand Education Society,


What does a derived class inherit from a base class a) Only the Public members of the base class b) Only the Protected members of the base class c) Both the Public and the Protected members of the base class d) .c file

0 Answers  


What is a stream in c programming?

0 Answers  


Categories