Syvum Home Page

Home > Quiz Games > C++ Programming > Print Preview

C++ Programming : Program 2-A

C++ Program to find the sum, difference, product and quotient of two integers


 

#include <iostream.h>
#include <conio.h>

void main()
{
  clrscr();
  int x = 10;
  int y = 2;
  int sum, difference, product, quotient;
  sum = x + y;
  difference = x - y;
  product = x * y;
  quotient = x / y;
  cout << "The sum of " << x << " & " << y << " is " << sum << "." << endl;
  cout << "The difference of " << x << " & " << "y <<  is " << difference << "." << endl;
  cout << "The product of " << x << " & " << y << " is " << product << "." << endl;
  cout << "The quotient of " << x << " & " << y << " is " << quotient << "." << endl;
  getch();
}

This program has pre-defined values for two integers x and y.
The sum, difference, product and quotient of these two values are calculated and then outputted using the 'cout' command.

No inputs from the user for this program.

The sum of 10 & 2 is 12.
The difference of 10 & 2 is 8.
The product of 10 & 2 is 20.
The quotient of 10 & 2 is 5.

Index of C++ Programs
 

-
-
 
45 more pages in C++ Programming

Contact Info © 1999-2024 Syvum Technologies Inc. Privacy Policy Disclaimer and Copyright