• +1-617-874-1011 (US)  
  • +44-117-230-1145 (UK)  
Online Customer Service
Follow Us:

Nested if-else statement

When If – Else is used within If-ElseStatement it is called as Nested If-Else Statement.

Syntax:

if (condition 1)
{
Statement to be executed when condition 1 true;
}
else
{
if (condition 2)
{
Statement to be executed when condition 2 is true;
}
else
{
Statement to be executed when condition 2 is false;
}
}

Nested If Else Statement Homework Help

Let us re-program the Indian railways ticket program using Nested If-Else Statement.

#include <stdio.h>
#include <conio.h>
int main()
{
int age;
printf(“Enter your age: ”);
scanf(“%d”,&age);

if (age <= 5)
{
printf(“you have 100% discount on your ticket.”);
}
else
{
if (age <= 12)
{
printf(“you have 50% discount on your ticket.”);
}
else
{
if (age <=26)
{
printf(“you have 10% discount on your ticket.”);
}
else
{
if (age > 60)
{
printf(“you have 25% discount on your ticket.”);
}
}
}
}
return;
}

In the above example we have implemented Nested If-Else Statement.

Topics in C Programming

PLACE ORDER NOW
 

Resources

  •   24 x 7 Availability.
  •   Trained and Certified Experts.
  •   Deadline Guaranteed.
  •   Plagiarism Free.
  •   Privacy Guaranteed.
  •   Free download.
  •   Online help for all project.
  • Need Assignment Help

Testimonial

Urgenthomework helped me with finance homework problems and taught math portion of my course as well. Initially, I used a tutor that taught me math course I felt that as if I was not getting the help I needed. With the help of Urgenthomework, I got precisely where I was weak:
Read More

Tap to Chat
Get Instant Assignment Help
Tap to Chat
Get Instant Assignment Help