Program to enter an integer and find out if it is even or odd

#include <iostream.h> #include <conio.h> void main() { clrscr(); int x; cout << “Enter an integer : “; cin>>x; if(x%2==0) cout << “The number ” << x << ” is even.”; else cout << “The number ” << x << ” is odd.”; getch(); }   This program takes in an integer x as a screen … Read more

Program to enter two integers and print the quotient and remainder

#include <iostream.h> #include <conio.h> int main() { clrscr(); int x,y,quotient,remainder; cout << “Enter 2 integers greater than 0 : “; cin>>x>>y; quotient=x/y; remainder=x-(quotient*y); cout << “Quotient of ” << x << ” & ” << y << ” = ” << quotient << “\n”; cout << “Remainder” << ” = ” << remainder << “\n”; … Read more

Program to enter an integer and output its 15 multiples

  #include <iostream.h> #include <conio.h> int main() { clrscr(); int x; cout << “Enter an integer less than 2185 : “; cin>>x; cout << “The first 15 multiples of ” << x << ” are : “; for(int y=1;y<16;y++) cout << “\n” << x << “x” << y << “=” << x*y; getch(); return 0; … Read more

Program to enter your age and print if you should be in grade 10

  #include <iostream.h> #include <conio.h> void main() { clrscr(); int age; cout << “Enter your present age : ” << endl; cin>>age; if(age==16) { cout << “Your present age is ” << age << ” years.” << endl; cout << “You are of the right age for joining grade 10 !” << endl; } else … Read more

Program to enter two integers and find their sum and average

#include <iostream.h> #include <iostream.h> #include <conio.h> void main() { clrscr(); int x,y,sum; float average; cout << “Enter 2 integers : ” << endl; cin>>x>>y; sum=x+y; average=sum/2; cout << “The sum of ” << x << ” and ” << y << ” is ” << sum << “.” << endl; cout << “The average of … Read more

C++ program which adds two integers

#include <iostream.h> main() { // A simple C++ program int x, y, sum; cout << “A program which adds two integers\n”; cout << “Enter 1st integer: “; cin >> x; cout << “Enter 2nd integer: “; cin >> y; sum = x + y; cout << “Sum is ” << sum << endl; return 0; … Read more