how to find the given number is prime or not?
Answer Posted / rahul tiwari
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=9
getch();
}
| Is This Answer Correct ? | 8 Yes | 7 No |
Post New Answer View All Answers
Are enumerations really portable?
What does double pointer mean in c?
How to draw the flowchart for structure programs?
Should I learn data structures in c or python?
Where define directive used?
PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM
Which function in C can be used to append a string to another string?
Should I learn c before c++?
Write a program to check prime number in c programming?
What is the equivalent code of the following statement in WHILE LOOP format?
What are the scope of static variables?
How do you declare a variable that will hold string values?
Give the rules for variable declaration?
Tell me is null always defined as 0(zero)?
What is the difference between c &c++?