write the program for prime numbers?

Answer Posted / oza priyanka

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

Is This Answer Correct ?    0 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the difference between the = symbol and == symbol?

625


What is %s and %d in c?

589


What does the c in ctime mean?

567


Is calloc better than malloc?

574


What is the use of function in c?

709






What is structure in c definition?

572


What is pointer to pointer in c?

634


What are examples of structures?

597


What is type qualifiers?

659


Write a program to reverse a given number in c language?

618


What is wrong with this declaration?

611


Why c language is called c?

569


What does a pointer variable always consist of?

663


What is signed and unsigned?

641


Is linux written in c?

598