Tag Archives: #mastery18

#Mastery18 – Nested Conditionals

Here´s the link to a youtube video explaining how to use nested conditionals.

 

Click here.

 

1017

18

Mastery 19

Use of loops with “while”

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:

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:

Mastery 19

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:

When the above code is compiled and executed, it produces the following result:

Credits:

http://www.tutorialspoint.com/cplusplus/cpp_while_loop.htm

1017 18 

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:

 

You can nest else if…else in the similar way as you have nested if statement.

Example:

When the above code is compiled and executed, it produces the following result:

Credits:

http://www.tutorialspoint.com/cplusplus/cpp_nested_if.htm

1017 18

M18 – Nesting of conditional statements

18

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://www.dropbox.com/s/0dawgtka55f54pi/M18%20-%20Nesting.mp4?dl=0

Mastery 18

Mastery 18

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://www.youtube.com/watch?v=n8kGRnubEoc

 

Nesting of conditional statements


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.

Mastery18

 

Here is the youtube link to mastery 18: https://www.youtube.com/watch?v=CeLnp1FGiB4

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:

<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;

}

#mastery18 https://www.youtube.com/watch?v=e0JEJq6YcZk

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://www.youtube.com/watch?v=RDteRZ56dPQ