--Originally published at my programming blog
When the teacher explained us the homework WSQ01 I was scared, I didn’t even know how to run the “Hello World” program, but right now I’m really proud of myself! It wasn’t as hard as I thought it would be, I read all chapter 2 of the book and it explains very well, also I read a post in the webpage cplusplus.com that also helped me. So thanks to this I understood how to do the program!
So what I did was:
- I typed the basic things like” #include <iostream>”, “using namespace std;” and “int main ()”
- Then I put an integer with the values of a and b
- Then I typed “cout<< ” First integer: “<<endl;
- Then typed “cin>> a; ” (“cin” means that you insert the value you want)
- The I typed “cout<< “Second integer: “<< endl;
- Again I typed “cin>> b;” ( but this time I entered the b value)
- And then I just typed “cout<< “Sum of the two numbers: ” << a+b << endl; (after the string I put operation I wanted which was the sum a+b)
- And I did the same with the different operations (difference, division and the remainder)
Here is my program:
#include <iostream>
using namespace std;
int main()
{
int a, b;
cout << “First integer: ” << endl;
cin >> a;
cout << “Second integer: ” << endl;
cin >> b;
cout << “Sum of the two numbers: ” << a+b << endl;
cout << “Difference of the two numbers: ” << a-b<< endl;
cout << “Integer based division of the two numbers: ” << a/b << endl;
cout << “Remainder of the integer division of the two numbers: ” << a%b << endl;
return 0;
}
Thanks for reading!