Variables & Data Types, Arithmetic operators, Relational Operators, if-else statements
In this article, we would understand the use of the Variables & Data Types, Arithmetic operators and Relational operators as well as providing you with 3 different projects that can help you understand these all things that we are going to cover.
Variables & Data Types
Variables are the containers that store different types of data. For instance, let’s assume that we have a basket that can store the apples. Now, there are 2 main things to remember:
- First of all, the basket has a certain capacity, meaning that if there are too many apples that basket can overflow. In programming, it is known data type overflow.
- Secondly, baskets can normally store anything they want to. In this case, the basket can only store the specific type of things, which are apples. Similarly, in programming, just one type of data can be stored in the variable.
These are different types of data types that we need to know in order to begin programming in c++.
int It is used to store a number.
float It is used to store a decimal number.
char It is used to store a single character like alphabet character ‘A’;
string It is used to store a text.
bool It is used to store only two values: true or false.
Arithmetic Operators
– Subtraction
+ Addition
* Multiplication
/ Division
% Module (It returns the remainder of the number.)
Relational Operators
== Equal to
!= Not Equal to
> Greater than
< Less than
>= Greater than or Equal to
<= Less than or Equal to
Projects to be done...
1) Create a program that shows odd and even numbers between 0-100.
2) Create a Youtube Rating Chatbot. (It isn’t as complicated as it sounds)
It should display three video titles:
- Introduction to C++ (Video)
- Variables & Data Types (Video)
- Arithmetic Operators
Users should be allowed to add the ratings ranging from 1-5.
If the rating is in between 1-2. Display a message “One or Two Stars”.
If the rating is 3 or 4. Display a message “3 or 4 Stars”.
If the rating is 5. Display a message “5 Stars”.
If the rating is out of range, meaning it isn’t in between 1-5. Display an error message “Error, Please start the process again”.
Comments are closed.