how to find the given number is prime or not?
Answer Posted / arunkumar mt
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int i,n,flag=0;
clrscr();
printf("enter a number\n");
scanf("%d",&n);
for(i=2;i<=sqrt(n);i++)
{
if(n%i==0)
{
flag=1;
break;
}
}
if(flag==0)
{
printf("given number %d is prime",n);
}
else
{
printf("given number %d is not prime",n);
}
getch();
}
Is This Answer Correct ? | 2 Yes | 3 No |
Post New Answer View All Answers
Is it cc or c in a letter?
What is the usage of the pointer in c?
A function can make the value of a variable available to another by a) declaring the variable as global variable b) Passing the variable as a parameter to the second function c) Either of the two methods in (A) and (B) d) binary stream
What is wrong with this initialization?
Why do we use header files in c?
What is the use of #define preprocessor in c?
how to print electricity bill according to following charges first 100 units -1rs per unit for next 200 units-1.50 rs per unit without using conditions
how to capitalise first letter of each word in a given string?
a construct the"else" part of "if" statement contains anoth "if else" statement is called a) if-else b) else-if-else c) if-else-if-else d) chain if/if-else-if
Who is the founder of c language?
Want to know how to write a C program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
When do we get logical errors?
What is difference between union and structure in c?
Is there any possibility to create customized header file with c programming language?
Explain the use of fflush() function?