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 prime no program in c++?

Answer Posted / waleed

#include<iostream.h>
#include<conio.h>

int prime(int);

void main()
{
clrscr();
int num,x;
cout<<"Enter the no.=";
cin>>num;
x=prime(num);
if(x==1)
{
cout<<"Number is prime";
}
else
{
cout<<"Number is not prime";
}

getch();
}

int prime(int x)
{
int k;
for(int i=2;i<x;i++)
{
if (x%i==0)
{
k=2;
}
}
if (k==2)
return 0;
else
return 1;


}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are compilers in c++?

1063


How can you tell what shell you are running on unix system?

1111


How can you quickly find the number of elements stored in a static array? Why is it difficult to store linked list in an array?

975


How would you call C functions from C++ and vice versa?

1168


Explain how overloading takes place in c++?

1042


What are libraries in c++?

1066


What is algorithm in c++ programming?

1124


Which is not an ANSII C++ function a) sin() b) tmpnam() c) kbhit()

1530


How do you differentiate between overloading the prefix and postfix increments?

1095


What is an object in c++?

1249


Is dev c++ free?

1043


Write about an iterator class?

1077


What is the difference between while and do while loop?

1152


What is function prototyping?

1095


Can I learn c++ without knowing c?

1059