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 a built-in function in C?

1597


Why do we use header files in c?

1071


What is the difference between a string and an array?

1202


Explain how do you list files in a directory?

1067


Can we change the value of constant variable in c?

1055


Create a structure to specify data on students given below: Roll number, Name, Department, Course, Year of joining Assume that there are not more than 450 students in the college. 1.write a function to print names of all students who joined in a particular year 2.write a function to print the data of a student whose roll number is given

3062


A program is required to print your biographic information including: Names, gender, student Number, Cell Number, line of study and your residential address.

1716


Explain about the functions strcat() and strcmp()?

1048


What does the format %10.2 mean when included in a printf statement?

1649


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

1428


Is c programming hard?

1019


State the difference between realloc and free.

1070


The file stdio.h, what does it contain?

1156


What is the difference between text and binary modes?

1192


What are near, far and huge pointers?

1055