Computer Science, asked by TbiaSamishta, 1 year ago

Write a program to find the square root of prime number in c.

Answers

Answered by anmol6433
5

#include<stdio.h>

int main()

{

int n, i = 3, count, c;

printf("Enter the number of prime numbers required\n");

scanf("%d",&n);

if ( n >= 1 )

{

printf("First %d prime numbers are :\n",n);

printf("2\n");

}

for ( count = 2 ; count <= n ; )

{

for ( c = 2 ; c <= i - 1 ; c++ )

{

if ( i%c == 0 )

break;

}

if ( c == i )

{

printf("%d\n", i);

count++;

}

i++;

}

return 0;

}

Answered by aqibkincsem
0

"Prime numbers are significant in computer science and programming. A prime number is that which is only can be divided by 1 or that number itself. In C program sqrt (square root) function is used to determine a number to be a prime number or not. To find the square root, the program is following:

#include<stdio.h>

#include<math.h>

void main( )

{

intnum,i;

int FLAG=1;

printf( “Enter any Positive Number” )

scanf( “%d” ,&num);

for(i=2;i<=sqrt(num);i++)

    {

if(num%i == 0)

          {

             FLAG = 0;

break;

          }

    }

if(FLAG == 1)

    {

printf( “%d is prime number n” ,num);

    }

return;

}

"

Similar questions