00:01
Hello student here the nested conditional statement shown below has been written by the inexperienced c+ + programmer.
00:08
The behavior of the statement is not correctly represented by the formatting.
00:13
So here the program is if n is less than 10 and if n is greater than 0 see out the number is positive otherwise the number is then n.
00:27
So here if i will what is the output of the statement if the variable n has a value 7.
00:34
So if i pass 7 if the variable n has a 7 the output will be the number is positive.
00:40
So it will execute see out this one and here output will be positive.
00:45
If the variable n has 15 the output will be again because both conditions satisfied n is greater.
00:52
So 10 here if n is less than 10 and after this it is asking if n is greater than 0.
01:01
So in this case n is greater than 0 then 15 will be printed here.
01:06
So because the number is positive so positive if n has a value minus 3 the output will be the number is negative or 0.
01:16
So in this case because in this case number will be printed like this.
01:21
So now we can correct the statement here.
01:25
The following is the corrected version of the statement with the syntax and the logic corresponding to the formatting of the original statement.
01:33
Here i am using first outer condition if n is greater than 0 then i have used the curly brace here.
01:41
Here n is greater than 0 then it is printing the number is positive.
01:47
Else if case if n is equal to 0 the number is 0 it must be printed and the another case else if both are not matching then it will be printed the number is negative.
02:00
So corrected formatting and logic of the statement...