Information and technology, FahadTheITGuy, programming languages, web development, desktop development, C, C++, C#, visual basic, HTML, CSS, javascript, jQuery, MS SQL server, in this blog, we will learn different programming languages and implement them with examples, we are also going to learn web development in asp.net, asp.net core, asp.net MVC, asp.net core mvc, we also learn about databases in ms SQL server, we will also cover databases, data structures, data mining, and wisdom mining
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 Of While Loop in C++ Programming Language Basic Working Of While Loop In C++ Programming Language Now we are going to discuss about the basic working of while loop in C++ programming....
Get link
Facebook
X
Pinterest
Email
Other Apps
If Else If ladder statement in C++ Programming Language
Get link
Facebook
X
Pinterest
Email
Other Apps
-
If Else If ladder statement in C++ Programming Language
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 ladder statement in C++ programming language.
In C++ programming language the if-esle-if ladder statement is a multi-way decision-making construct, it allows us to test different conditions in sequence, and executing the block of code associated with the first condition that evaluates to be true.
Syntax of if-else-if ladder statement in C++ programming language
if(condition1)
{
//code to be executed if condition1 is true
}
else if(condition2)
{
//code to be executed if condition2 is true
}
else if(condition3)
{
//code to be executed if condition2 is true
}
else
{
//code to be executed if all the conditions are false
}
Basic working of if-else-if ladder statement
In if-else-if ladder statement first of all there is an if condition in the start of if-else-if ladder. If that condition is true then the code block after if condition will run and the remaining else-if and else conditions will be ignored.
But if the first if condition is false, then the program will check else-if conditions and if any of those conditions are true the program will run that peace of code under that specific else-if block.
Let us look at simple example of if-else-if ladder statement in C++ program
In above given example we print a message to the console screen that to enter a number. Once we enter a number then the entered number is checked by the if-else-if ladder statement.
First of all the if condition is checked in which we specified that if entered number is equal to 10 then simply print a message that entered number is 10. And if the first condition is false then the else-if condition will run which checkes that if the entered number is equal to 20 it will simply print the message that entered number is 20, and if that condition isi false then the next else-if will run.
And if all the conditions are false then the else part will run which indicates that the entered number is not 10, 20, or 30.
So, in this way the if-else-if ladder statement is executed successfully.
Congratulations! like always we have successfully implemented the if-else-if ladder statement program.
How to Run C project in Visual Studio Community 2022 Many people think we cannot write c code in the visual studio community. but this is completely not true, yes we can create a C file and run C code in Visual Studio 2022 let us see how we can achieve it. 1) Open Visual Studio 2022 First of all, we are going to open Visual Studio 2022. 2) creating a new project Then we are going to create a new project by clicking create new project button. 3) choosing a project template: Create a new project window that will appear in front of you. From this window select an empty project template with C++ symbol on it. Then push the next button. 4) configure your project A new window will appear in front of you with the heading Configure your new project. In this window, you can select your project and solution name. And also the location of your project. then click the Create button. 5) New project created: On clicking the create button a C++ project is go...
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 Of While Loop in C++ Programming Language Basic Working Of While Loop In C++ Programming Language Now we are going to discuss about the basic working of while loop in C++ programming....
If and if-else statements in the 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 if(condition) { //code to be executed here } Simple if coding example ...
Comments
Post a Comment