Tag Archives: or not

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 »

Write a program in ‘C’ to check whether the given year is leap or not. Also explain the logic of the program. 8m Dec2008

Write a program in ‘C’ to check whether the given year is leap or not. Also explain the logic of the program. 8m Dec2008 The leap year formula is: A leap year is divisable by 4, but not by 100 (except if divisable by 400.)   #include<stdio.h> void main(){ int year; clrscr(); printf(“Enter any year:… Read More »