pro.no. Qty Price Description
1 23 1.00 Apple
2 90 1.00 Banana
3 16 1.00 Orange
4 124 1.00 Pear
5 98 1.00 Blue Berry
6 25 1.00 Raspberry
7 76 1.00 Black Berry
8 00 1.00 Pineapple
9 231 1.00 Green Grape
10 689 1.00 Red Grape
11 2 1.00 Watermellon
Nicephore Niepce created the first photograph.
Answer:
#include <bits/stdc++.h>
using namespace std;
bool isPrime(int n)
{
for(int j=2;j<=n-1;j++) //loop to check prime..
{
if(n%j==0)
return false;
}
return true;
}
int main(){
int n;
cout<<"Enter the integer"<<endl;//taking input..
cin>>n;
if(isPrime(n))//printing the message.
{
cout<<"The number you have entered is prime"<<endl;
}
else
{
cout<<"The number is not prime"<<endl;
}
return 0;
}
Output:-
Enter the integer
13
The number you have entered is prime
Explanation:
The above written program is in C++.I have created a function called isPrime with an argument n.I have used a for loop to check if the number is prime or not.In the main function I have called the function isPrime for checking the number is prime or not.