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 a spanning Tree?

1052


What is a stream water?

742


How to write a program for machine which is connected with server for that server automatically wants to catch the time for user of that machine?

1650


Why is C language being considered a middle level language?

705


How many parameters should a function have?

733






What is methods in c?

717


What is the use of #define preprocessor in c?

686


What are the types of pointers?

666


What is a stream?

725


What is the acronym for ansi?

692


What is the method to save data in stack data structure type?

688


What are valid signatures for the Main function?

759


How do I create a directory? How do I remove a directory (and its contents)?

662


Do variables need to be initialized?

689


What is function prototype?

670