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

What is the difference between ++a and a++?

694


How is actual parameter different from the formal parameter?

591


Write a program to print ASCII code for a given digit.

688


What is typedf?

670


Is that possible to add pointers to each other?

901






Write a code to achieve inter processor communication (mutual exclusion implementation pseudo code)?

689


Is r written in c?

724


Is there any demerits of using pointer?

631


Explain 'far' and 'near' pointers in c.

706


Write a program to reverse a string.

640


What is structure of c program?

607


how can f be used for both float and double arguments in printf? Are not they different types?

608


Why do we use int main?

610


How does normalization of huge pointer works?

639


What is an array? What the different types of arrays in c?

660