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 / awais

A PROG TO CHECK ANY NUMBER IS PRIME OR NOT BY USING IF ELSE STATEMENT
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter number");
scanf("%d",&x);
if(x==1)
{
printf("the number is neither composite nor prime");
}
else if(x==2)
{
printf("the number is prime");
}
else if(x%2==0)
{
printf("the number is not prime");
}
else if(x%2!=0)
{
printf("the number is prime");
}
getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is substring in c?

1256


Is exit(status) truly equivalent to returning the same status from main?

1115


How do you override a defined macro?

1312


Can variables be declared anywhere in c?

1147


Give a one-line C expression to test whether a number is a power of 2. [No loops allowed - it's a simple test.]

1129


What is a memory leak? How to avoid it?

1421


In c programming write a program that will print 10 multiples of 3 except 15,18,21 using looping

1588


Which operators cannot be overloaded a) Sizeof b) .* c) :: d) all of the above

1190


List the difference between a "copy constructor" and a "assignment operator"?

1061


Explain the use of 'auto' keyword

1171


Why is python slower than c?

1131


What's the right way to use errno?

1200


how to find anagram without using string functions using only loops in c programming

3231


What is && in c programming?

1221


i = 25;switch (i) {case 25: printf("The value is 25 ");case 30: printf("The value is 30 "); When the above statements are executed the output will be : a) The value is 25 b) The value is 30 c) The value is 25 The value is 30 d) none

1119