how to find the given number is prime or not?
Answer Posted / rajamanickam.m
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int n,flag=0,ctr;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=sqrt(n);ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==0)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
getch();
}
| Is This Answer Correct ? | 3 Yes | 2 No |
Post New Answer View All Answers
How many loops are there in c?
write a C program:There is a mobile keypad with numbers 0-9 and alphabets on it. Take input 0f 7 keys and then form a word from the alphabets present on the keys.
What is ponter?
List some applications of c programming language?
What are data structures in c and how to use them?
Was 2000 a leap year?
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
What are the types of variables in c?
What is a constant?
Are bit fields portable?
What does void main return?
If null and 0 are equivalent as null pointer constants, which should I use?
Can you please explain the difference between exit() and _exit() function?
What are local static variables?
How can I recover the file name given an open stream?