Posts

Nested Loops In C++ Programming Language

Image
  Nested  Loops In C++ Programming Language We have studied about loops in C++ programming language. There are three looping statements that we worked with so far i.e, while loop, do-while loop, and for loop. We know that we use loops when we want to repeat or iterate some piece of code according to our programming logic and requirement.  In this blog post we are going to look at nested loops in C++ programming language. Now the first question arises that what is a nested loop. At this point so far we already have knowledge about loops. Nested loops are nothing they are just a loop that is placed or resides completely inside another loop. In simple words it is a loop inside another loop. And remember one important point, the inner loop completes all of its iterations every single time the outer loop runs once. Basic Syntax Of Nested Loops In C++ Programming Language Syntax of for loop in C++ programming language for (initialization; condition; i...

Do-While Loop in C++ Programming Language

Image
  Do-While Loop In C++ Programming Language The do-while loop is an exit-controlled loop. We have studied about loops before in our previous blog posts let us now look at the do-while loop in C++ programming language.  An interesting thing about do-while is that this loop executes at-least once no matter if the given condition is true or false at the very first iteration. It means in both the cases if condition is true or false the do-while will run and execute the piece of code. After that the given condition will decide wether the do-while loop will run or not if the condition is false then the do-while loop will terminate and not run for the second iteration and if the condition is still true then the do-while loop will run. Basic Syntax of Do-while Loop in C++ Programming Language Syntax of do-while loop int i = 1; do { // code to be executed here. // variable to be incremented i++. } while (condition); Working of Do-While...

While Loop in C++ Programming Language

Image
           While Loop in C++ Programming Language We have discussed about the entry-controlled loop or pre-tested loop previously in our blog posts. These statements or loops are used to repeat a piece of code for a specific number of times as per our program requirement.  We have studied about the for loop already. Today in this blog post we are going to study about the while loop in C++ programming language. And we will look at how this while loop actually works and how we can stop it by making some condition false so that the loop might not run infinitely. We use while loop in C++ program when the number of iterations is not known in advance and depends on the condition. When we know exactly, that how many times a loop should run then we use the for loop instead of while loop. Basic syntax and working of while loop in C++ programming language Syntax of while loop int i = 1; while (condition) { // code of b...

For Loop In C++ Programming Language

Image
  For Loop In C++ Programming Language In Programming languages looping statements are used with the help of these looping statements we can repeat some block of code according to our requirement of the program.  In C++ programming language we also use these looping statements, these looping statements are also referred as controlled structure . In this blog post we are going to cover for loop statement which is used to execute a block of code repeatedly for a specific number of times. The for loop is " entry controlled " or " pre-tested " loop which means that the condition is checked before the code inside the loop ever runs. We use for loop when we know exactly how many times the loop will going to run. Basic syntax and working of for loop in C++ programming language Syntax of for loop  for (initialization; condition; increment) { // code to be executed here. } Working of for loop in C++ programming language Now let us...

Switch statement in C++ programming language

Image
  Switch statement in C++ programming language In todays blog post we are going to cover a very important decision making statement which is used to execute or run different blocks of code based on the value of the expression. Always remember that the switch statement is used as an alternate to the if else if ladder statement in C++ programming language. The switch statement is more cleaner and is considered to be more efficient as compared to the if else if ladder statement. And just keep this thing in mind that, the expression value that is used with in the switch statement it must be an integer value, or a character value, or enumeration type. In programming languages we have studied about conditional statements in which accross given set of conditions we chose any specific condition and run the block of code as per that condition. There are other techniques that we call control statement or decision making statements.  The Switch statement is one of th...

If Else If ladder statement in C++ Programming Language

Image
  If Else If ladder statement in C++ Programming Language Today in this blog post we are going to cover another very important conditional statement which is known as if else-if ladder statement. In C++ programming language we have studied about the if statement, if else statement, and today our focus is on if else if ladder statement in C++ programming language. The if else if ladder statement is a multi-way decision making structure with the help of which we can test multiple conditions in a sequential manner from top to bottom. And in a very simple way if any if any of the else if conditions become true it will execute that specific piece of code, and ignores the remaining else if conditions without even checking them. In programming languages we have conditional statements or decision making statements that we can use in order to make decisions among multiple conditions. Today we are going to cover a simple conditional statement which is known as if-else-if ladde...

if and if else statement in C++ programming language

Image
  If and if-else statements in C++ programming language In this blog post we will look at the basic working of if and if-else statement in C++ programming language. These if and if-else statements are also referred as conditinal statements in programming languages. But today we will study them under the context of C++ programming. In C++ programming language we use if and if-else to run a specific peace of code under one condition and another peace of code for some different condition. We also refer them as decision statements . Types of if statements in C++ programming language If we talk about types of if statements there are mainly four types 1) if statement 2) if-else statement 3) if else-if ladder statement 4) nested if statements But in this blog post we will cover the if and if-else statements. Syntax of if statement and basic working of if statement Syntax of if statement if (condition) { // code to be executed here. ...

Popular posts from this blog

How to Download and Install Microsoft visual studio community 2022 for free

For Loop In C++ Programming Language

Hello World Program In C Programming Language