Question #14353

accept a long integer from user and check whether square root of a number is prime or not.

Expert's answer

#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;

}

#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;

}

## Comments

## Leave a comment