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 / varun raj s p

#include<stdio.h>

int main()
{
int n, i = 3, count, c;

printf("Enter the number of prime numbers required\n");
scanf("%d",&n);

if ( n >= 1 )
{
printf("First %d prime numbers are :\n",n);
printf("2\n");
}

for ( count = 2 ; count <= n ; )
{
for ( c = 2 ; c <= i - 1 ; c++ )
{
if ( i%c == 0 )
break;
}
if ( c == i )
{
printf("%d\n",i);
count++;
}
i++;
}

return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Which header file should you include if you are to develop a function which can accept variable number of arguments?

1397


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

1144


what is the diffrenet bettwen HTTP and internet protocol

1837


Write a C program to count the number of email on text

1915


What is file in c language?

1004


Explain what is wrong with this program statement?

1120


Explain the use of fflush() function?

1083


Calculate 1*2*3*____*n using recursive function??

2038


what does static variable mean?

1102


Why do we need volatile in c?

1166


What is sizeof array?

1056


Implement bit Array in C.

1140


What is a function in c?

1577


How can you find out how much memory is available?

1069


What is an expression?

1055