Answer to Question #14353 in C++ for kushagra kumar
accept a long integer from user and check whether square root of a number is prime or not.
1
2012-09-14T09:29:49-0400
#include<stdio.h>
#include <conio.h>
#include <math.h>
int main()
{
int num ;
int sqrtnum;
printf("Enter the number: ");
scanf("%d",&num);
int i;
sqrtnum=pow(num,0.5);
for (i=2; i < sqrtnum ;i++ ){
int n = sqrtnum%i;
if (n==0){
printf("not Prime!");
break;
}
}
if(i == sqrtnum){
printf("Prime number!");
}
getch();
return 0;
}
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!
Learn more about our help with Assignments:
C++
Comments
Leave a comment