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

Answer Posted / md.ershad ezaz

#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,c;
clrscr();
printf("Enter a number\n");
scanf("%d",&n);
c=0;
for(i=1;i<=n;i++)
{
if(n%i==0)
c=c+1;
}
if(c==2)
printf("%d is prime",n);
else
printf("%d is not prime",n);
getch();
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is define c?

568


What is a built-in function in C?

784


Why is c faster?

588


What is a pragma?

662


What is struct node in c?

612






why return type of main is not necessary in linux

1697


Which header file is essential for using strcmp function?

932


What are multidimensional arrays?

652


Explain the difference between exit() and _exit() function?

630


Explain what is #line used for?

603


Can include files be nested? How many levels deep can include files be nested?

651


How does selection sort work in c?

617


Explain how can I right-justify a string?

616


What was noalias and what ever happened to it?

590


What is the best style for code layout in c?

628