Tag Archives: is prime

CPP04 – (b) Write a CPP program to print whether a number is prime or not .

(b) Write a CPP program to print whether a number is prime or not . CODE:- #include<iostream.h> #include<conio.h> void main() { int NUM,I; clrscr(); cout<<“ENTER A NUMBER :”; cin>>NUM; for(I=2;I<NUM;I++) { if(NUM%I==0) break; } if(I==NUM) cout<<NUM<<” IS A PRIME NUMBER”<<endl; else cout<<NUM<<” IS NOT A PRIME NUMBER”<<endl; getch(); } [codesyntax lang=”cpp”] #include<iostream.h> #include<conio.h> void main()… Read More »