answersLogoWhite

0


Best Answer

int is_prime(int n){

int flag=1;

if(n==1)

return 0;

int root=(int)sqrt(n);

while(root!=1){

if(n%root==0){

flag=0;

break;

}

root--;

}

return flag;

}

User Avatar

Wiki User

12y ago

Still curious? Ask our experts.

Chat with our AI personalities

LaoLao
The path is yours to walk; I am only here to hold up a mirror.
Chat with Lao
ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
BlakeBlake
As your older brother, I've been where you are—maybe not exactly, but close enough.
Chat with Blake

Add your answer:

Earn +20 pts
Q: C program to find whether the given number is prime or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a program to find whether the given number is prime or not and show output?

#include<stdio.h> #include<conio.h> void main() { int n,a=2; clrscr(); printf("\n enter n"); scanf("%d",&n); if(i<=a-1) { if(a%i==0) { printf("\n the given number is not a prime number"); break; } i++; if(a==i) { printf("\n the given number is a prime number"); } getch(); output: enter the value of n:2 the given number is prime number


With a given big integer number which is the product of two prime numbers how do you find them?

First write a program to generate the prime number. After one prime number was generated, divide the big int number by the prime number. If the remainder is zero then quotient is the second prime number ( also it is important to check whether the quotient is prime number or not because sometimes you will get wrong answer). Repeat the process until you get the result.


Draw a flow chart to check whether a given number is prime or not?

[object Object]


Does a prime number always go an equal number of times?

No. A given number need not even be divisible by a given prime.


Write a c program to find given number is prime or not?

Yes, do write, or if you're too lazy to your homework, use google.


Write a shell script to check whether the given input is prime or not?

shell script for check whether the given no is prime or not??echo "input any number:"read nono=`expr $no`i=`expr 2`while [ $i -lt $no ]doif [ `expr $no % $i` -eq 0];thenecho "$no is not a prime no.."break 2fii=`expr $i +1`doneif [ $i -eq $no ];thenecho "$no is a PRIME no..."fi


What is the only given prime number?

The only even prime number is 2.


What is a prime number that can be divided exactly into the given number?

That's a prime factor.


How can you decide whether a number is a prime number?

Any number that cannot be evenly divided by any prime number smaller than itself is a prime number.


How are factors and prime numbers related?

Whether a number is a prime number or not is determined by its factors. It is a prime number if its only factors are 1 and itself.


What is the only prime number that is a factor of the number 16?

prime factor = prime number which can be divided into the given number with no remainder ie 2


A program to find that the input number is prime or not?

Use Wolfram|Alpha... go to the related link below, Wolfram|Alpha, and type in (is __ (number) prime) and then the program will compute that and tell you if it is prime or composite.