Lab Manual 05
Lab Manual 05
LAB MANUAL 05
Lab Objectives:
At the end of this lab students will know about
If else Statements:
If condition returns true then the statements inside the body of “if” are executed and the statements inside
body of “else” are skipped.
If condition returns false then the statements inside the body of “if” are skipped and the statements in
“else” are executed.
if(condition) {
// Statements inside body of if
}
else {
//Statements inside body of else
}
if(condition) {
//Nested if else inside the body of "if"
if(condition2) {
//Statements inside the body of nested "if"
}
else {
//Statements inside the body of nested "else"
}
}
else {
//Statements inside the body of "else"
Switch Statements:
In computer programming languages, a switch statement is a type of selection control mechanism used to
allow the value of a variable or expression to change the control flow of program execution via a multi-
way branch.
Syntax:
switch (a) {
case 1:
//some statements
break;
case 2:
break;
default:
break;
Question#01
Solutions:
#include <iostream>
Using namespace std;
int main()
{
char ch;
if((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
{
cout<<"character is an alphabet.";
}
else
{
cout<<"character is not alphabet.";
}
return 0;
}
Question #02
Write a C++ program to input angles of a triangle and check whether triangle is valid or not.
Question #03
Question #04
Write a menu driven C++ program for simple calculator using if-else.
Question #05
Write a program to input three numbers and find maximum between all.
Question #06
Write a C++ program that tells the user that the number entered is less than, greater than or equal to 10?
Question #07
Write a C++ program that tells the user that the number entered is even or odd?
Question #08
Write a menu driven C++ program that ask the user to choose the type in which he wants the output?
Question #09
According to your grading system mark the user entered percentage as Grade A, B, C, D, F?