Programming Fundamentals Lab 05 (Nested If-Else and If-Else-If Statements)
Programming Fundamentals Lab 05 (Nested If-Else and If-Else-If Statements)
Sample Program.
Write a program which takes marks as input and then shows output as follows:
Marks Output
87 – 100 Grade A
80 - 87 Grade B+
72 – 80 Grade B
67 – 72 Grade C+
60 - 67 Grade C
Below 60 Failed
Sample Code:
#include <stdio.h>
int main()
{
int marks;
printf ( “Enter an marks\n”);
scanf ( “%d”, &marks );
Write a program, which takes age as input from user and prints appropriate message depending upon the
following conditions:
If age less than 6 then prints, “What a nice child!”
If age is between 6 and 9 then prints, “That’s a good age!”
If age is between 9 and less than 20 then prints, “Ah! In the prime of life”
If age between 20 and less than 30 then prints, “Watch out, the younger ones are gaining on
you.”
More than 30 then it prints, “Well, have fun, and don’t look back.”
Task 2:
Write a program which takes 3 numbers as input then it finds the minimum and maximum number and
print output as follows:
Task 3:
Write a program in which it takes two numbers from keyboard as input and subtract larger
number from smaller?
Task 4:
Write a Program using Nested if-else structure. The program will get a Single Character from
user and Tell either it is Vowel or Not and it a capital or small letter?
Sample output:
Enter a character : A
A is a Vowel and it is Capital Letter.
Enter a character: y
y is not a Vowel and it is small Letter.