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

Is the exit() function same as the return statement? Explain.

654


Q.1 write a program to create binary tree 1 to 16 numbers? Q.2 write a program to creat a binary search tree for the member that is given by user?

2051


Explain the priority queues?

617


Differentiate between full, complete & perfect binary trees.

667


typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none

705






Explain how does flowchart help in writing a program?

620


There seem to be a few missing operators ..

611


write a programe to accept any two number and check the following condition using goto state ment.if a>b,print a & find whether it is even or odd and then print.and a

1445


Explain that why C is procedural?

650


How macro execution is faster than function ?

658


What is the use of pragma in embedded c?

585


Once I have used freopen, how can I get the original stdout (or stdin) back?

620


Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

2504


What is the purpose of clrscr () printf () and getch ()?

591


c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above

725