Posts

Showing posts with the label switch statement in c++

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 Basic Working of Do-While Loop in C++ Programming Language As we know that these looping statements are used to repeat or iterate some piece of code. In do-while loop first we sho...

Switch statement in c programming language

Image
  Switch statement in c programming language What Is a switch statement? The switch statement is a conditional statement that we use to run different code sections based on some conditions. The switch statement also works like the if else-if else ladder statement. As we know in the else-if ladder statement we implement multiple conditions it is exactly how the switch statement works. In the switch statement, we use the term case: that tells us about any specific condition within the switch expression area switch(expression).   What is the syntax of a switch statement in c programming switch(Some_Epression) { case value1: // insert code here break; case value2: // insert code here break; default: // insert code here } Rules and regulations of switch statement: Always remember that the expressions that are used within the switch statement i.e. switch(expression), this expression must be a single character or an integer value. As discussed earlier  case: ...