write the program for prime numbers?

Answer Posted / pran pratim

#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int num,i,count=0;
cout<<"Enter the number::";
cin>>num;
for(i=2;i<=num/2;i++)
{
if(num%i==0)
{
count++;
break;
}
}
if(count==0)
{
cout<<"The number is Prime";
}
else
cout<<"The number is Composite";
getch();
}

Is This Answer Correct ?    2 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is wrong with this program statement? Void = 10;

768


Can a local variable be volatile in c?

584


What is wild pointer in c?

613


How are structure passing and returning implemented?

594


What is extern variable in c with example?

544






What is s or c?

603


What is typedef example?

621


What is wrong with this declaration?

615


Which driver is a pure java driver

996


Explain pointers in c programming?

640


Is exit(status) truly equivalent to returning the same status from main?

589


What is an identifier?

632


Why is c platform dependent?

627


What math functions are available for integers? For floating point?

627


Can a pointer be volatile in c?

539