Skip to main content

Posts

Showing posts from May 14, 2020

Nested if Statements In C Programming

NESTED if STATEMENTS: In simple words an if statement inside another if statement is called Nested if statement. Syntax: if(condition 1) { if(condition 2) {code if condition 1 and 2 both are satisfied;} } Example Code: Write a program to find whether the number entered by the user lies in a particular range. Ans: #include<stdio.h> #include<conio.h> void main() { int n; getch(); printf("\n enter the number "); scanf("%d",&n); if(a>0) { if(a<18) { printf("\n the entered number is in the given range"); } else {  printf("\n the entered number is not in the given range"); } } else { printf("\n the number is not in the given range); } getch(); } The above code is written in code blocks Output: enter the number 17 the entered number is in the given range Explanation of the above Code: In the above code we have declared an variable of data type integ