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 the use of the function in c?
What is variables in c?
How can variables be characterized?
Is it better to bitshift a value than to multiply by 2?
What is the use of static variable in c?
Give differences between - new and malloc() , delete and free() ?
What is the equivalent code of the following statement in WHILE LOOP format?
What is class and object in c?
List the difference between a 'copy constructor' and a 'assignment operator' in C?
a parameter passed between a calling program and a called program a) variable b) constant c) argument d) all of the above
Explain how can a program be made to print the line number where an error occurs?
Explain the use of keyword 'register' with respect to variables.
How can you find the day of the week given the date?
Is multithreading possible in c?
A variable that is defined in a specified portion of a program but can be used throughout the program a) global variable b) local variable c) character d) none