write the program for prime numbers?

Answer Posted / awais

A PROG TO CHECK ANY NUMBER IS PRIME OR NOT BY USING IF ELSE STATEMENT
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int x;
printf("enter number");
scanf("%d",&x);
if(x==1)
{
printf("the number is neither composite nor prime");
}
else if(x==2)
{
printf("the number is prime");
}
else if(x%2==0)
{
printf("the number is not prime");
}
else if(x%2!=0)
{
printf("the number is prime");
}
getch();
}

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I remove the trailing spaces from a string?

618


Explain what does the function toupper() do?

638


What do you mean by a sequential access file?

631


What is function definition in c?

590


What is the modulus operator?

742






What are linker error?

618


What is the use of getchar() function?

634


Explain which function in c can be used to append a string to another string?

594


What is c programming structure?

622


What are qualifiers in c?

575


why use "return" statement a) on executing the return statement it immediately transfers the control back to the calling program b) it returns the value present in the parentheses return, to the calling program c) a & b d) none of the above

613


What is variable in c example?

596


What are the 4 types of functions?

575


How can I invoke another program (a standalone executable, or an operating system command) from within a c program?

656


Differentiate fundamental data types and derived data types in C.

621