Skip to main content

Posts

Showing posts from August 21, 2020

Decision Making Statements in C++.

The smallest Independent Unit in a C++ program is a statement i.e. You can relate it to sentences of a natural language. Because, Just like sentences are terminated with a period (.), similarly the statements are also terminated with semicolon (;) The simplest form of a program statement is the empty statement i.e.( ;) (NOTE - I will not be explaining this topic so much because, It is mostly known by every programmer, doesn't not matter if he/she is a beginner or a professional) Let's discuss the Decision Making Statements one by one. 1. If Statement - These statements are used when you want something to happen if your condition is true. Consider an example like this - If it's rainy outside I will bring an Umbrella with me. #include<iostream> using namespace std; int main () { bool rain = true ; if (rain == true ) // It can simply be written as if(rain){} { cout << "Take an Umbrella with you" << endl; } } A