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 / pawan kumar

#include<stdio.h>

int main(){

int num,i,count=0;
printf("Enter a number: ");
scanf("%d",&num);
for(i=2;i<=num/2;i++){
if(num%i==0){
count++;
break;
}
}
if(count==0 && num!= 1)
printf("%d is a prime number",num);
else
printf("%d is not a prime number",num);
return 0;
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where are c variables stored in memory?

1022


What are the __date__ and __time__ preprocessor commands?

1034


What do you mean by recursion in c?

1052


When should we use pointers in a c program?

1080


What does %d do in c?

907


Can you tell me how to check whether a linked list is circular?

1321


find out largest elemant of diagonalmatrix

2171


Why is c so powerful?

1061


What is the difference between int main and void main in c?

1092


How do I use void main?

1049


Write a c program to demonstrate character and string constants?

2111


Why c is procedure oriented?

994


Explain how can I prevent another program from modifying part of a file that I am modifying?

1034


What is the translation phases used in c language?

1056


What are the 5 types of organizational structures?

1016