Write a program in C++ to check the number is prime or not.
#include<iostream.h>
#include<conio.h> void main() { int a,b,c=0,d; clrscr(); cout<<”Enter any number”; cin>>a; d=0; for(b=2;b<a;b++) { c=a%b; if(c==0) d=d+1; } if(d==0) { cout<<”Prime number”; } else { cout<<”Not prime”; } getch(); } |