Answer to Question #5374 in C++ for anum

Question #5374
Q#1 WRITE A PROGRAM WHICH TAKES A NUMBER FROM THE USER, FIND THAT WHETHER ITS PRIME NUMBER NUMBER OR NOT? USING FUNCTION.
1
Expert's answer
2011-12-01T08:24:29-0500

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

//calculation
int isprime(int valuex)
{
int x,j;
x=1;
& for (j=2 ; j<valuex2; j++)
{ if ((valuex%j)==0) x=0; }
& if(x!=0) return 1;
& else return 0;
}

void main(){
int isprime(int);
int value;

//input
cout<<"Enter a number to verify whether it is prime or not "<<endl;
cin>>value;

//output
& if (isprime(value)==1) cout<<"Yes the number is prime"<<endl;
& else cout<<"Sorry, not a prime"<<endl;
& getch();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS