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
please explain clearly about execution of c program in detail,in which stage are the printf sacnf getting into exeecutable code
Where does the name "C" come from, anyway?
how should functions be apportioned among source files?
Explain how can I convert a number to a string?
Explain how do you override a defined macro?
hi send me sample aptitude papers of cts?
Which is best book for data structures in c?
Write a code to remove duplicates in a string.
Is c a great language, or what?
What are data types in c language?
Write a code of a general series where the next element is the sum of last k terms.
Explain what are reserved words?
What does node * mean?
Write a C/C++ program to add a user to MySQL. The user should be permitted to only "INSERT" into the given database.
Explain what is the benefit of using #define to declare a constant?