Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

The __________ attribute is used to announce variables based on definitions of columns in a table?

1252


Explain what is a program flowchart and explain how does it help in writing a program?

1143


Write a program to check prime number in c programming?

1146


Is void a keyword in c?

1052


What is uint8 in c?

1162


What is difference between structure and union in c?

1036


What is the difference between array and linked list in c?

1204


What is ctrl c called?

1098


What are qualifiers and modifiers c?

1063


I need previous papers of CSC.......plz help out by posting them.......

2350


What is main return c?

1050


What is a pointer in c?

1695


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

1153


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

1293


What is the difference between int main and void main in c?

1236