how to find the given number is prime or not?
Answer Posted / shweta
#include<stdio.h>
#include<conio.h>
void main()
{
int n,ctr=2,flag=0;
printf("enter the number to be checked\n");
scanf("%d",&n);
for(ctr=2;ctr<=n/2;ctr++)
{
if(n%ctr==0)
{
flag=1;
break;
}
}
if(flag==1)
printf("the given number is prime\n");
else
printf("the given number is not prime\n");
flag=0;
getch();
}
| Is This Answer Correct ? | 2 Yes | 5 No |
Post New Answer View All Answers
What is meant by preprocessor in c?
Difference between exit() and _exit() function?
Is c still used?
What is the use of getch ()?
What is the difference between functions abs() and fabs()?
Explain what is wrong with this program statement? Void = 10;
How can you find the day of the week given the date?
For what purpose null pointer used?
the maximum length of a character constant can be a) 1 character b) 8 characters c) 256 chaacters d) 125 characters
a sequence of bytes with one to one corrspondence to those in the external device a) sequential addressing b) address c) byte code d) none
How many loops are there in c?
How to Throw some light on the splay trees?
What is the difference between printf and scanf in c?
What is extern c used for?
How to implement a packet in C