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

What are actual arguments?

1055


What is a memory leak? How to avoid it?

1272


Write a Program to find whether the given number or string is palindrome.

1241


how to write optimum code to divide a 50 digit number with a 25 digit number??

3213


What should malloc() do? Return a null pointer or a pointer to 0 bytes?

1029


What 'lex' does?

1112


List some basic data types in c?

981


Differentiate between a for loop and a while loop? What are it uses?

1147


What is an array in c?

1008


what is the diffrenet bettwen HTTP and internet protocol

1799


Explain continue keyword in c

972


How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

985


What is the difference between ++a and a++?

1161


Explain the difference between strcpy() and memcpy() function?

959


What is the value of h?

995