Wednesday, 13 February 2019

If, if else and nested if program in c language 2019

If ,if else and nested if program in c language

If statement in c  language

Syntax:


Example:


If else statement in c programming language

Syntax:


Example:


Nested if statement in c language:


Syntax:

Example:

#include<stdio.h>
int main()
{
//Assigning value to the variable
int x=10;

if(x>5)//checking the condition
{
  if(x<15)//checking the condition
     {
     printf("x is greater than 5 and less than 15");
     }

}
}

### output ###
x is greater than 5 and less than 15




Combined program if ,if else and nested if statement in c language


1.  Write a program greater value of two number.

###Output###
Enter first number 45
Enter second number 50
Second no is greater 


2. Write a program greater value in three number.

###output###
Enter first number 50
Enter second number 60
Enter third number40
60 is greater


3.Check given no is positive or negative or zero.


###Output###
   
Enter any number
10
No is positive


4.   Show result according to percent using if statement.

###Output##

Enter your percent
65
First division


5.  Write a login program.

                  }

###Output###
Enter user name
easy@gmail.com
Enter password
12345
Login successful

6. Check character is vowel or consonent.


###Output###
Enter any alphabet
e
Vowel


7.   Write a voting program.


###output###.

Enter your age 
20
You are eligible for voting

8.     Write a program to find given no is even or odd.


###Output###

Enter any number
5
Odd


9.  Input three angle of triangle and check triangle is valid or not.


###Output###
Enter first angle
45
Enter second angle
85
Enter third angle
50
Triangle is valid

10.  Calculate profit or loss.

###Output###

Enter cost price
70
Enter selling price
50
Loss is 20

No comments:

Post a Comment

If, if else and nested if program in c language 2019

If ,if else and nested if program in c language If statement in c  language Syntax: Example: If else statement in c ...