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 / karthikeyan murugesan

hi u can try this one for prime number and generation ::
#include<stdio.h>
void main()
{
int n,i=1,j,c;
scanf("%d",&n);
while(i<=n)
{
c=0;
for(j=1;j<=i;j++)
{
if(i%j==0)
c++;
}
if(c==2)
{
printf("%d",i);
i++;
}
}
getch();
}

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between formatted&unformatted i/o functions?

1105


What's the best way of making my program efficient?

1151


Given below are three different ways to print the character for ASCII code 88. Which is the correct way1) char c = 88; cout << c << " ";2) cout.put(88);3) cout << char(88) << " "; a) 1 b) 2 c) 3 d) constant

1206


Why do we use & in c?

1051


What is the difference between NULL and NUL?

1351


What does node * mean?

1304


How does pointer work in c?

1194


What is static and auto variables in c?

1141


Can I initialize unions?

1090


Differentiate between #include<...> and #include '...'

1114


What is the function of this pointer?

1454


Where does the name "C" come from, anyway?

1215


a direct address that identifies a location by means of its displacement from a base address or segment a) absolute address b) relative address c) relative mode d) absolute mode

1174


Why is structure important for a child?

1148


Can we declare variable anywhere in c?

1034