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
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 |
How to find the usage of memory in a c program
Why doesnt long int work?
What is the explanation for cyclic nature of data types in c?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
Can we access array using pointer in c language?
How do c compilers work?
Explain bit masking in c?
What is a pragma?
what is the most appropriate way to write a multi-statement macro?
Which of the Following will define a type NODE that is a node in a Linked list? A)struct node {NODE*next;int x;};type def struct node NODE; B)typedef struct NODE {struct NODE *next;int x;}; C)typedef struct NODE {NODE *next;int x;}; D)typedef struct {NODE *next;int x;}NODE;
What is class and object in c?
What does the error 'Null Pointer Assignment' mean and what causes this error?