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

i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....

1917


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

1143


Write a program to print "hello world" without using a semicolon?

1003


What is the default value of local and global variables in c?

983


A text file that contains declarations used by a group of functions,programs,or users a) executable file b) header file c) obj file d) .cfile

1051


Is that possible to add pointers to each other?

1318


Can we use visual studio for c?

1009


How can you call a function, given its name as a string?

1099


What is the general form of a C program?

978


What is the difference between arrays and pointers?

1066


What are the advantages of union?

1023


Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent

2074


What is the size of enum in c?

1058


Compare array data type to pointer data type

967


Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

1074