Movatterモバイル変換


[0]ホーム

URL:


C Nested if-else Statements

C Programming Tutorials

Overview of C LanguageC Language FundamentalsData Input and OutputDecision Control StatementsLoop Control StatementsFunctionsPreprocessors and Header FilesArrays and StringsPointersStructure and UnionFile Handling

Nested "if else statements" play an essential role in C programming; It simply means the use of conditional statements inside another conditional statement.

The basic format of the Nested if-else statement is:

Syntax:

if(test_expression one){    if(test_expression two) {    //Statement block Executes when the boolean test expression two is true.    }}else{//else statement block}

Example of a C Program to Demonstrate Nested if-else Statement

Example:

#include<stdio.h>void main(){    int x=20,y=30;    if(x==20)    {        if(y==30)        {            printf("value of x is 20, and value of y is 30.");        }    }}

Execution of the above code produces the following result.

Output:

value of x is 20, and value of y is 30.

Nested if-else Statements in C - Video Tutorial

Please watch this video tutorial to understand "C Nested if-else Statements" in more depth.



Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram

[8]ページ先頭

©2009-2025 Movatter.jp