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


Please Help Members By Posting Answers For Below Questions

What is malloc() function?

648


What are bitwise shift operators in c programming?

656


What is the difference between text files and binary files?

686


Explain what is output redirection?

674


What is difference between far and near pointers?

622






What is the significance of scope resolution operator?

870


what is the format specifier for printing a pointer value?

622


What are pointers?

642


How can I invoke another program or command and trap its output?

628


What is printf () in c?

592


Explain what is the benefit of using enum to declare a constant?

596


what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)

1936


What's the right way to use errno?

635


can anyone suggest some site name..where i can get some good data structure puzzles???

1655


What is difference between %d and %i in c?

705