write the program for prime numbers?

Answer Posted / pratibha

#include<stdio.h>
#include<conio.h>
void main()
{
int no,i,count=0;
clrscr();
printf("enter the no");
scanf("%d",&no);
for(i=1;i<=no;i++)
{
if(no%i==0)
{
count=count+1;
}
}
if(count<=2)
{
printf("this is prime no");
}
else
{
printf("this is not prime");
}
getch();
}

Is This Answer Correct ?    17 Yes 14 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do you initialize pointer variables?

611


Is c# a good language?

605


What do you mean by Recursion Function?

628


What is the translation phases used in c language?

631


What is dynamic variable in c?

565






What are the storage classes in C?

621


Program to find the sum of digits of a given number until the sum becomes a single digit. (e.g. 12345=>1+2+3+4+5=15=>1+5=6)

687


Write a program of advanced Fibonacci series.

706


Which is better malloc or calloc?

649


What is difference between && and & in c?

595


What is || operator and how does it function in a program?

625


What does 3 periods mean in texting?

598


Is Exception handling possible in c language?

1581


What is logical error?

605


Explain what is the difference between a free-standing and a hosted environment?

635