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
The __________ attribute is used to announce variables based on definitions of columns in a table?
Explain what is a program flowchart and explain how does it help in writing a program?
Write a program to check prime number in c programming?
Is void a keyword in c?
What is uint8 in c?
What is difference between structure and union in c?
What is the difference between array and linked list in c?
What is ctrl c called?
What are qualifiers and modifiers c?
I need previous papers of CSC.......plz help out by posting them.......
What is main return c?
What is a pointer in c?
main use of recursive function a) processing speed high b) reduce program length/reduce repeated statements c) if you do not, use iterative methods like, for, while or do-while d) all the above
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What is the difference between int main and void main in c?