Fun with numbers! #WSQ03

2 min read

This is a program that asks you for two numbers, you type them and then it calculates the sum, difference, product, division and the remainder of the division of the two numbers.Screenshot of my program

The first thing I did was to download a word processor called Notepad++, to write the code there and save it as a C++ source file. When saving the code, you need to give it the name you want and put at the end .cpp like this: yourprogram.cpp. This is necessary to enable the program to be compiled. Now that you named the file, you need to save it in the User’s folder located in: C:/cygwin/home/Users(your computer’s name). Now, open the Cygwin Terminal, write: g++ yourprogram.cpp and click enter. It won’t be compiled if your program have a sintax error and the black screen will return an error message, if it doesn’t have any, it won’t return anything, like in the image below.

Screenshot of cygwin terminal

Once your program is compiled, you can run it, just type: ./a.exe

and press Enter.

To save and run the code, I watched this video made by Mr. Ken Bauer.

https://www.youtube.com/watch?v=5lJ6evIAndo&list=PLhMUtn5hqperLvPZugufj25uy8KW9ZrNP&index=3

To write the code, I watched this one also made by Mr. Ken.

https://www.youtube.com/watch?v=JFncCPhD76M&feature=youtu.be&list=PLhMUtn5hqperLvPZugufj25uy8KW9ZrNP

In this video he explains how to print messages in the screen by using the object cout and this arrows << and he also explains how to save the input (what the person types), as a variable by using the objetc cin and the arrows >>.

I also consulted the pages 4-8 of the book ”How to think like a computer scientist” written by Allen B. Downey.

 

 

CC BY 4.0 Fun with numbers! #WSQ03 by Alan Valdovinos is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.