Shares
print sharing button Print
twitter sharing button Tweet
facebook sharing button Share
whatsapp sharing button Share
pinterest sharing button Pin
email sharing button Email
buffer sharing button Share
surfingbird sharing button Share
arrow_left sharing button
arrow_right sharing button

C - if if or nested if Conditional Statements

<<Previous

Next >>



if if or nested if control statements

In C programming, we can use one if statement inside the another if statement. This is known as nested if statement.

If if or nested if - Syntax

if(conditional-expression-1)
{
	/* statements can be executed only the conditional_expression_1 is true */
	statement1;
	if(conditional-expression-2)
	{
		/* statements can be executed only the conditional_expression_2 is true */
		statement2;
	}
}

If else if Example C Program for Nested if statement

#include <stdio.h>

int main()
{
	int A=10;
	int B=15;
	if (A < B){
	   printf("Value of A is less than Value of B \n");
	   if (A > 5){
		   printf("This is inner if statement\n");
		   A = A - 5;
	     }
	}
	printf("Value of A is: %d ",A);
	return(0);
}

Output

Value of A is less than Value of B
This is inner if statement
Value of A is: 5

<< Previous

Next >>




strcat() - String Concatenation        strcmp() - String Compare


strcpy() - String Copy        strlen() - String Length














C - if if or nested if Conditional Statements

<<Previous

Next >>



if if or nested if control statements

In C programming, we can use one if statement inside the another if statement. This is known as nested if statement.

If if or nested if - Syntax

if(conditional-expression-1)
{
	/* statements can be executed only the conditional_expression_1 is true */
	statement1;
	if(conditional-expression-2)
	{
		/* statements can be executed only the conditional_expression_2 is true */
		statement2;
	}
}

If else if Example C Program for Nested if statement

#include <stdio.h>

int main()
{
	int A=10;
	int B=15;
	if (A < B){
	   printf("Value of A is less than Value of B \n");
	   if (A > 5){
		   printf("This is inner if statement\n");
		   A = A - 5;
	     }
	}
	printf("Value of A is: %d ",A);
	return(0);
}

Output

Value of A is less than Value of B
This is inner if statement
Value of A is: 5

<< Previous

Next >>






strncat() - String n Concatenation        strlwr() - String Lower       

strncmp() - String n Compare       strncpy() - String n Copy