Write a program to find whether the given number is prime or
not?
Answer Posted / nikhilreddy gujjula
#include<stdio.h>
#include<conio.h>
void main()
{
int prime=1;
int n,i;
printf("enter a number");
scanf("%d",&n);
if(i=2;i<=n/2;i++)
{
if((n%i)==0)
{
prime=0;
break;
}
}
if(prime==1)
{
printf("%d is a prime number",n);
}
else
{
printf("%d is not a prime number",n);
}
getch();
}
Is This Answer Correct ? | 5 Yes | 5 No |
Post New Answer View All Answers
What is malloc() function?
What are bitwise shift operators in c programming?
What is the difference between text files and binary files?
Explain what is output redirection?
What is difference between far and near pointers?
What is the significance of scope resolution operator?
what is the format specifier for printing a pointer value?
What are pointers?
How can I invoke another program or command and trap its output?
What is printf () in c?
Explain what is the benefit of using enum to declare a constant?
what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)
What's the right way to use errno?
can anyone suggest some site name..where i can get some good data structure puzzles???
What is difference between %d and %i in c?