write the program for prime numbers?
Answer Posted / kiran
#include<iostream>
#include<stdio.h>
#include<conio.h>
using namespace std;
int main()
{
int tn=1,c=0,flag=0;;
cin>>tn;
for(int i=3; c!=tn;i++)
{for(int j=2;j<i;j++)
{
if(i%j==0){
flag=0; break;}
else flag=1;
}
if(flag)
{c++;
printf("%d,",i);
}
}
getch();
return 0;
}
| Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
Explain what are bus errors, memory faults, and core dumps?
Define VARIABLE?
Can we use any name in place of argv and argc as command line arguments?
Where are local variables stored in c?
Explain what is wrong with this program statement? Void = 10;
What is pre-emptive data structure and explain it with example?
hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?
What is return type in c?
Why do some versions of toupper act strangely if given an upper-case letter?
What are the advantage of c language?
What are nested functions in c?
What is the difference between memcpy and memmove?
What are loops in c?
Is null equal to 0 in sql?
What are the differences between new and malloc in C?