Hello dear readers. This is my first post and it is of great importance, because it reflects the beginning of the programs that I will create throughout the semester.

“Fun with numbers” is the first problem that Professor Ken Bauer assigned us.  The task was to create a program that complies with the points shown in the image and thereby solve the problem.

It was a challenging activity, which helped me learn basic commands for c ++ . The language is simple to understand once you study a little. The book “How to think like a computer scientist” was very useful to conceive my code, in addition to several videos of youtube.

I hope you enjoy my program and really understand the whole code 😀

Luis Felipe Garate Moreno.

#include <iostream>
using namespace std;

int main()
{
int a,b,r1,r2,r3,r4,r5;  //Declaration of variables , r=result.

cout <<“This program performs several operations from two numbers and provides the results” << endl;
cout << “Give me the first number:” << endl;
cin >> a;       //Variable for the first number.
cout << “Give me the second number:” << endl;
cin >> b;       //Variable for the second number.

r1 = a + b;   //Sum
cout <<“The sum of the two numbers=” << r1 << endl;
r2 = a – b;   //Subtraction
cout <<“The difference of the two numbers=” << r2 << endl;
r3 = a * b;   //Multiplication
cout <<“The product of the two numbers=” << r3 << endl;
r4 = a / b;   //Division
cout <<“The integer based division of the two numbers=” << r4 << endl;
r5 = a % b;   //Remainder of integer division
cout <<“The remainder of integer division of the two numbers=” << r5 << endl;

return 0;
}

_____________________________________________________________

Advertisement