Write a program to find whether the given number is prime or
not?

Answer Posted / padhmavathi loganathan

#include<stdio.h>
int main()
{
int a,i,f;
printf("Enter a number: ");
scanf("%d",&a);
f=0;
i=2;
while(i <= a/2)
{
if(a%i == 0)
{
f=1;
break;
}
i++;
}
if(f==0)
printf("Prime Number")
else
printf("Not Prime Number");
return 0;
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is the benefit of using const for declaring constants?

624


How would you rename a function in C?

629


Can a local variable be volatile in c?

588


Can you mix old-style and new-style function syntax?

672


console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above

668






Is it possible to initialize a variable at the time it was declared?

769


What language is c written?

585


Describe the modifier in c?

614


What is a program?

674


Differentiate between a structure and a union.

775


PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE

1482


Explain high-order bytes.

687


Explain null pointer.

630


What are c preprocessors?

687


How can I check whether a file exists? I want to warn the user if a requested input file is missing.

666