//c program to find prime number
#include<stdio.h>
#include<conio.h>
int main()
{
int num, count=0, i;
printf ( "enter your number:" );
scanf ( "%d" ,&num);
for(i=1; i<=num; i++)
{
if (num%i==0)
{
count++;
}
}
if (count <= 2)
{
printf ("number is prime");
}
else
{
printf ("number is not prime");
}
return 0;
}
----------------------------------------------------------------------------------------------
//c++ program to find prime number
#include <iostream>
using namespace std;
int main()
{
int num, count=0, i;
cout << "\n enter your number: ";
cin >> num;
if (num==1)
{
cout << "\n 1 is a prime number";
}
else
{
for(i=1; i<=num; i++)
{
if (num%i==0)
{
count++;
}
}
if (count==2)
{
cout << "number is prime";
}
else
{
cout << "number is not prime";
}
}
return 0;
}
#include<stdio.h>
#include<conio.h>
int main()
{
int num, count=0, i;
printf ( "enter your number:" );
scanf ( "%d" ,&num);
for(i=1; i<=num; i++)
{
if (num%i==0)
{
count++;
}
}
if (count <= 2)
{
printf ("number is prime");
}
else
{
printf ("number is not prime");
}
return 0;
}
----------------------------------------------------------------------------------------------
//c++ program to find prime number
#include <iostream>
using namespace std;
int main()
{
int num, count=0, i;
cout << "\n enter your number: ";
cin >> num;
if (num==1)
{
cout << "\n 1 is a prime number";
}
else
{
for(i=1; i<=num; i++)
{
if (num%i==0)
{
count++;
}
}
if (count==2)
{
cout << "number is prime";
}
else
{
cout << "number is not prime";
}
}
return 0;
}
No comments:
Post a Comment