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
What is a spanning Tree?
What is a stream water?
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?
Why is C language being considered a middle level language?
How many parameters should a function have?
What is methods in c?
What is the use of #define preprocessor in c?
What are the types of pointers?
What is a stream?
What is the acronym for ansi?
What is the method to save data in stack data structure type?
What are valid signatures for the Main function?
How do I create a directory? How do I remove a directory (and its contents)?
Do variables need to be initialized?
What is function prototype?