DESCRIPTION-:THIS PROGRAM IS USED TO CHECK WHETHER THE ENTERED
NUMBER IS PRIME OR NOT.
A PRIME NUMBER IS ONE WHICH IS NOT DIVISIBLE BY ANY OTHER
NUMBER EXCEPT ITSELF .FOR EXAMPLE 5,43,23,17.......
PROGRAM-:
#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
int n;
char ch;
do
{
cout<<"enter the number";
cin>>n;
for (int i=2;i<=n/2;i++)
{
if(n%i==0)
{
cout<<"no is not prime";
goto start;
}
}
cout<<"no is prime";
start:
cout<<"u waana further continue(Y/y)";
cin>>ch;
}
while(ch=='y'||ch=='Y');
getch();
}
NUMBER IS PRIME OR NOT.
A PRIME NUMBER IS ONE WHICH IS NOT DIVISIBLE BY ANY OTHER
NUMBER EXCEPT ITSELF .FOR EXAMPLE 5,43,23,17.......
PROGRAM-:
#include<iostream.h>
#include<conio.h>
#include<process.h>
void main()
{
clrscr();
int n;
char ch;
do
{
cout<<"enter the number";
cin>>n;
for (int i=2;i<=n/2;i++)
{
if(n%i==0)
{
cout<<"no is not prime";
goto start;
}
}
cout<<"no is prime";
start:
cout<<"u waana further continue(Y/y)";
cin>>ch;
}
while(ch=='y'||ch=='Y');
getch();
}
0 comments:
Post a Comment