This is th video for masteries 9 and 10 Basic types and their use in C++ Basic output (printing) and input (text based) in C++ Here is the link
This is th video for masteries 9 and 10 Basic types and their use in C++ Basic output (printing) and input (text based) in C++ Here is the link
Basic types and their use in Python.
Basic output (print) in Python
Basic types and their use in Python.
Basic output (print) in Python
Mastery 7 – Use of comments in Python You may understand your code perfectly just after you wrote it, but if someone else tries to know what you did or some years later you want to accurately remember what you had done, it can get tricky, but worry not! Comments are your saviour! On Python, comments’ syntaxis […]
Mastery 7 – Use of comments in Python You may understand your code perfectly just after you wrote it, but if someone else tries to know what you did or some years later you want to accurately remember what you had done, it can get tricky, but worry not! Comments are your saviour! On Python, comments’ syntaxis […]
Here is video of mastery 10 😀
Hope it helps.
It’s about:
- Basic output (printing) and input (text based) in C++
A computer program can do two main things, ask for information or give the user new information. This two concepts are input and output, and it’s what we are going to talk about in this post. First, their definition: Output:… Continue Reading →
Basic output (printing) and input (text based) in C++
Today, I’m going to show you some basic input and output in C++.
On masteries 1 & 7 we learned some basic output, which is used as “cout”. cout is used when the program prints information you gave it to it in the program. When you want to input information from the terminal, while the program is running, you need a variable and the “cin” command.
In order to do this, we will create a program that asks the user for two integer numbers, and then the program will add those numbers and then print the result.
So, you will need our “basic code” that we learned on masteries 1 & 7:
Now that we have our basic code, we will write the program inside the braces.
The first thing we need to do, is to establish the variables we are going to use. We need two variables for the numbers the user is going to input in the program and another variable that will work as the result.
The variables need to be established inside the braces, and are written as:
int FIRSTVARIABLE, SECOND, THIRD;
Now that we have our variables, we can tell the program what it needs to do. For that, we will simply do as follows:
- Print (cout) a question where the program asks the user for the variables (cin)
- Write a math operation with the variables
- Print the result:
And that’s it. You can use this principle to perform other math operations:
Now, run your program in the terminal. Remember to change the directory, compile your program and then run it:
You now know how to do a basic program with inputs and outputs, congrats! 😀