Answer to Question #14353 in C++ for kushagra kumar

Question #14353
accept a long integer from user and check whether square root of a number is prime or not.
1
Expert's answer
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!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS