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


Please Help Members By Posting Answers For Below Questions

What is wrong with this initialization?

590


What is a const pointer in c?

670


What is a volatile keyword in c?

636


Why is c not oop?

535


what is the format specifier for printing a pointer value?

609






List some basic data types in c?

557


Explain About fork()?

644


Can i use “int” data type to store the value 32768? Why?

756


what is the difference between 123 and 0123 in c?

719


Explain 'far' and 'near' pointers in c.

704


write a program to create a sparse matrix using dynamic memory allocation.

4373


What is c standard library?

690


will u please send me the placement papers to my mail???????????????????

1361


What is modifier & how many types of modifiers available in c?

609


Explain modulus operator.

595