home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C Programming Starter Kit 2.0
/
SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso
/
tybc4
/
oper1.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1993-03-18
|
1KB
|
44 lines
// simple C++ program to illustrate simple math operations
#include <iostream.h>
main()
{
int int1, int2;
long long1, long2, long3, long4, long5;
float x, y, real1, real2, real3, real4;
cout << "\nType first integer : ";
cin >> int1;
cout << "Type second integer : ";
cin >> int2;
cout << "\n";
long1 = int1 + int2;
long2 = int1 - int2;
long3 = int1 * int2;
long4 = int1 / int2;
long5 = int1 % int2;
cout << int1 << " + " << int2 << " = " << long1 << '\n';
cout << int1 << " - " << int2 << " = " << long2 << '\n';
cout << int1 << " * " << int2 << " = " << long3 << '\n';
cout << int1 << " / " << int2 << " = " << long4 << '\n';
cout << int1 << " mod " << int2 << " = " << long5 << '\n';
cout << "\n\n";
cout << "Type first real number : ";
cin >> x;
cout << "Type second real number : ";
cin >> y;
cout << "\n";
real1 = x + y;
real2 = x - y;
real3 = x * y;
real4 = x / y;
cout << x << " + " << y << " = " << real1 << '\n';
cout << x << " - " << y << " = " << real2 << '\n';
cout << x << " * " << y << " = " << real3 << '\n';
cout << x << " / " << y << " = " << real4 << '\n';
cout << "\n\n";
return 0;
}