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 you increase the allowable number of simultaneously open files?

595


what is the height of tree if leaf node is at level 3. please explain

1602


What is void pointers in c?

586


4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.

1727


Why n++ execute faster than n+1 ?

1846






What is the meaning of 2d in c?

611


explain what is fifo?

632


What are local static variables? How can you use them?

645


Hi can anyone tell what is a start up code?

1616


Explain how many levels deep can include files be nested?

626


What will the preprocessor do for a program?

588


Differentiate between the = symbol and == symbol?

712


How to declare pointer variables?

686


What is a const pointer in c?

670


What is putchar() function?

635