Ahora en este programa, que fue el según que hice, programé operaciones matematicas, las 4 mas sencillas y comunes, simplemente trata de que el programa le pida al user 2 números, y cuando se los dé, el programa le de la suma, resta, división, multiplicación y el residuo, como era el segundo programa todavía no sabia bien que hacer así que busque un ejemplo en esta liga: https://www.programiz.com/cpp-programming/examples/add-numbers y si me ayudo, pero para entender algunas dudas le pregunte a mi professor.
En mi este programa también se pueden apreciar 2 sencillo mastery topics, uno es numero 4 que es el print, en mi programa se aprecia al inicio, después de declarar mis variables, cuando pongo la función cout, al correrlo se desplegara la string que ponga ahí.
Y el opuesto a este es el mastery05, el de input, que su función es que el usuario escriba algo y se guarde como valor de una variable, se representa como cin. Como se puede observar soy capaz de usar a mi antojo estas dos funciones.
My second programming activity was also simple, but a little bit longer than the first one, because in this case I had to declare some variables (I could have not declared that quantity of variables and still my program would have run the same way, but it seemed to me that it was easier for me to read it and organize the lines in my code.) Previously had to read some pages in the Book, to understand and know how to declare some variables to make simple arithmetic operations and print in the screen the results of these.
Hello! curious readers. “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.
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 like program and really understand the whole code
The assignment for week 2 was Fun with Numbers. It consisted on developing a program in which the user could type in two numbers and the program would display the sum, difference, product, quotient, and remainder of these.
To do this, I read through the chapter of How To Think Like a Computer Scientist on Operators. When I got the basic idea, I began to write the code. As soon as I started doing this I realized that I knew that I had to create a variable for each of the numbers that the user would type, but I didn’t know how inputs worked, so I looked it up online and found a few webpages that explained it. It was pretty simple, thus I finished my code and tried running it.
On my first attempt my code would only display the first part of the program, so I thought that I hadn’t understood inputs quite well, but when I looked further into it, I saw that what I had was a syntax error: I was missing the “<<” between my string output and my operation outputs. I typed in the missing “<<” and ran the program again, this time successfully!
Here are the links that helped me develop the wsq01:
I was already a little bit familiar with programming in c++ before this, so this first program was really easy to me. Though I had to remember a few things because I hadn’t program in like 10 months.
For this I use an app in my phone call “Learn C++”. I don’t recommend it for actually learning, it is more like a review or practice kind of thing. For this first topic the information is in the first unit called “Basic Concepts”.
The code in general looks small, but I thought convenient to show the “results”.
Note: I used the line: “cout<<endl;” merely for aesthetic reasons. The purpose of this is to jump a line so the results won’t be all in the same line.
This is the first program I made after setting up my software and programed “Hello World” and since that I have been reading and searching information about programming in C++ because I have never used it before, I do have a little bit of experience programming but not in C++, it has not been very difficult neither easy.
This program is very basic, teacher Ken asked us to made something that: Ask the user for two integer values, then use those two values to calculate and show the following:
The sum of the two numbers.
The difference of the two numbers.
The product of the two numbers.
The integer based division of the two numbers (so no decimal point). First divided by second.
The remainder of integer division of the two numbers.
So this is what I made:
I already had an idea of how to start something in C++ thanks to “Hello World” but I needed to look up for information about the variables, the operators and how to show the results in the book: “How to Think Like a Computer Scientist, C++ Version”, Downey, Allen B. 2012.
My code is:
using namespace std;
int main ()
cout << “Please enter an integer value: “;
cin >> a;
cout << “Please enter another integer value: “;
cin >> b;
cout << ” their sum is ” << a+b << “.\n”; //The sum of the two numbers.
cout << ” their difference is ” << a-b << “.\n”; //The difference of the two numbers.
cout << ” their product is ” << a*b << “.\n”; //The product of the two numbers.
cout << ” their int division is ” << a/b << “.\n”; //The integer based division of the