Skip to content

Instantly share code, notes, and snippets.

@itguy51
Created April 8, 2015 04:01
Show Gist options
  • Save itguy51/d5850d71b5062ac5542f to your computer and use it in GitHub Desktop.
Save itguy51/d5850d71b5062ac5542f to your computer and use it in GitHub Desktop.
ECE114_02
//Standard iostream include (get cin/cout)
#include <iostream>
//Commented out, I just live with .
using namespace std;
int main(){
int i1, i2, i3, i4, i5, i6, i7, i8;
float f1, f2;
//Read In.
cout << "Enter 2 numbers: ";
cin >> i1 >> i2;
//Sum.
i3 = i2 + i1;
//Print it.
cout << "Sum: " << i3 << "\r\n";
// i1 - i2
i4 = i1 - i2;
//Print it.
cout << "Number 1 minus Number 2: " << i4 << "\r\n";
// i2 - i1
i5 = i2 - i1;
//Print it.
cout << "Number 2 minus Number 1: " << i5 << "\r\n";
// i1 * i2
i6 = i1*i2;
//Print it.
cout << "Product: " << i6 << "\r\n";
// i1/i2
f1 = (float)i1 / i2;
//Print it.
cout << "Number 1 divided by Number 2: " << f1 << "\r\n";
//i2/i1
f2 = (float)i2 / i1;
//Print it.
cout << "Number 2 divided by Number 1: " << f2 << "\r\n";
//i1 mod i2
i7 = i1 % i2;
//Print it.
cout << "Number 1 mod Number 2: " << i7 << "\r\n";
//i2 mod i1
i8 = i2 % i1;
//Print it.
cout << "Number 2 mod Number 1: " << i8 << "\r\n";
//Check which is greater.
if (i1 == i2){
cout << "Numbers are equal.\r\n";
}
else if (i1 > i2){
cout << "Number 1 is greater than number 2.\r\n";
}
else if (i1 < i2){
cout << "Number 2 is greater than number 1.\r\n";
}
//Optional Part.
cout << "sizeof(short int): " << sizeof(short int) << "\r\n";
cout << "sizeof(int): " << sizeof(int) << "\r\n";
cout << "sizeof(long int): " << sizeof(long int) << "\r\n";
cout << "sizeof(char): " << sizeof(char) << "\r\n";
cout << "sizeof(float): " << sizeof(float) << "\r\n";
cout << "sizeof(double): " << sizeof(double) << "\r\n";
//Return 0 status code.
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment