Write a program to find whether the given number is prime or
not?
Answer Posted / padhmavathi loganathan
#include<stdio.h>
int main()
{
int a,i,f;
printf("Enter a number: ");
scanf("%d",&a);
f=0;
i=2;
while(i <= a/2)
{
if(a%i == 0)
{
f=1;
break;
}
i++;
}
if(f==0)
printf("Prime Number")
else
printf("Not Prime Number");
return 0;
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is difference between arrays and pointers?
What is the use of #include in c?
How can I make sure that my program is the only one accessing a file?
Why c is called procedure oriented language?
Write a program to display all the prime nos from 1 to 1000000, your code should not take time more than a minute to display all the nos.
How can I remove the leading spaces from a string?
what are the facialities provided by you after the selection of the student.
Why we not create function inside function.
What is the purpose of main( ) in c language?
What does the message "automatic aggregate intialization is an ansi feature" mean?
What is static memory allocation? Explain
What are header files in c?
Write a program to reverse a string.
What does it mean when a pointer is used in an if statement?
What is structure in c explain with example?