write a program to read in a positive integer and


Write a program to read in a positive integer and check whether it is prime or not?

/* Program to check whether a given number is prime or not*/]

# include

# include

void main()

{

int i=2,n,flag=1;

clrscr();

printf("\nEnter the number : ");

scanf("%d",&n);

while(i

{

if(n%i==0)

{

flag=0;

printf("\n%d is not a prime number",n);

break; /*takes control out of the while as soon as the numbers is fully divisible */

}

else i++;

}

 

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: write a program to read in a positive integer and
Reference No:- TGS0305496

Expected delivery within 24 Hours