-
Recent Posts
Recent Comments
Archives
Categories
Meta
Tag Archives: #mastery18
#Mastery18 – Nested Conditionals
Comments Off on #Mastery18 – Nested Conditionals
Posted in Blogs, Syndicated, TC1017 Blogs
Tagged #mastery18, #TC, #TC1017, Mastery
Mastery 19
Use of loops with “while”
A while loop statement repeatedly executes a target statement as long as a given condition is true.
Syntax:
The syntax of a while loop in C++ is:
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;">while(condition) { statement(s); }
Here, statement(s) may be a single statement or a block of statements. The condition may be any expression, and true is any non-zero value. The loop iterates while the condition is true.
When the condition becomes false, program control passes to the line immediately following the loop.
Flow Diagram:
Here, key point of the while loop is that the loop might not ever run. When the condition is tested and the result is false, the loop body will be skipped and the first statement after the while loop will be executed.
Example:
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-image: url('http://www.tutorialspoint.com/cplusplus/images/try-it.jpg') !important; background-attachment: initial !important; background-color: #eeeeee !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: 100% 0%; background-repeat: no-repeat !important;">#includeusing namespace std; int main () { // Local variable declaration: int a = 10; // while loop execution while( a 20 ) { cout "value of a: " a endl; a++; } return 0; }
When the above code is compiled and executed, it produces the following result:
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;">value of a: 10 value of a: 11 value of a: 12 value of a: 13 value of a: 14 value of a: 15 value of a: 16 value of a: 17 value of a: 18 vuale of a: 19
Credits:
Mastery 18
Nesting of conditional statements
It is always legal to nest if-else statements, which means you can use one if or else if statement inside another if or else if statement(s).
Syntax:
The syntax for a nested if statement is as follows:
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;">if( boolean_expression 1) { // Executes when the boolean expression 1 is true if(boolean_expression 2) { // Executes when the boolean expression 2 is true } }
You can nest else if…else in the similar way as you have nested if statement.
Example:
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; cursor: default; background-image: url('http://www.tutorialspoint.com/cplusplus/images/try-it.jpg') !important; background-attachment: initial !important; background-color: #eeeeee !important; background-size: initial !important; background-origin: initial !important; background-clip: initial !important; background-position: 100% 0%; background-repeat: no-repeat !important;">#includeusing namespace std; int main () { // local variable declaration: int a = 100; int b = 200; // check the boolean condition if( a == 100 ) { // if condition is true then check the following if( b == 200 ) { // if condition is true then print the following cout "Value of a is 100 and b is 200" endl; } } cout "Exact value of a is : " a endl; cout "Exact value of b is : " b endl; return 0; }
When the above code is compiled and executed, it produces the following result:
#d6d6d6; font-size: 12px; overflow: auto; color: #313131; background-color: #eeeeee;">Value of a is 100 and b is 200 Exact value of a is : 100 Exact value of b is : 200
Credits:
M18 – Nesting of conditional statements
#Mastery18
Hey everybody! In this video I talk about how to nest different conditionals to acomplish a process or validate some answers. I hope you enjoy it!
https:/
Comments Off on M18 – Nesting of conditional statements
Posted in Blogs, Syndicated, TC1017 Blogs
Tagged #mastery18, Mastery
Mastery 18
Comments Off on Mastery 18
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #mastery18, Sin categoría
mastery18 Nested if statements
well for this mastery I made a video in wich I explain what is nested if statements and when we used it. For do the video interactive I create a very simple code and run in the terminal.
here is the link: https:/
Comments Off on mastery18 Nested if statements
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #mastery18, #TC1014
Nesting of conditional statements
Nesting of conditional statements
At this point we already know how to use conditionals, but we can have one conditional inside the other. This is in order to have several options of answers of the program in use, or many other options.
This is very useful because with only con conditional there’s no much place to work, but you can add as many conditions as you want to your code, and the posibilities are huge.
In my example there are two conditions, one to let you know that you passed, and the other, in case your grade is above 9 points, it congratulates you.
It’s very easy to do and it will be coming handy.
#TC1017 #mastery18
Comments Off on Nesting of conditional statements
Posted in Blogs, Syndicated, TC1017 Blogs
Tagged #mastery18, #TC1017
Mastery18
#Mastery18 #TC1017 #nowinhd #lol
Here is the youtube link to mastery 18: https:/
So basically nested conditional statements allow us to create an if-else statement that validates more than two options for one variable, here is an example:
#include <iostream>
using namespace std;
int main(){
int a;
cout<<“give me a: “<<endl;
cin>>a;
if (a<0){
cout<<“less”<<endl;
}else {
if(a==0){
cout<<“equals “;
}else{
cout<<“greater “;
}
}
return 0;
}
Comments Off on Mastery18
Posted in Blogs, Syndicated, TC1017 Blogs
Tagged #include, #lol, #mastery18, #nowinhd, #TC1017
#mastery18 https://www.youtube.com/watch?v=e0JEJq6YcZk
Comments Off on #mastery18 https://www.youtube.com/watch?v=e0JEJq6YcZk
Posted in Blogs, Syndicated, TC1017 Blogs
Tagged #mastery18
Mastery 18. Nested conditional Statements
For this mastery I created avideo where I explain what Nested conditional statements are and how to use them.
Here is the link to my video: https:/
Comments Off on Mastery 18. Nested conditional Statements
Posted in Blogs, Syndicated, TC1014 Blogs
Tagged #mastery18, #TC1014