0% found this document useful (0 votes)
17 views2 pages

CSC - 111 - Lab 11

Uploaded by

Muhammad Osama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views2 pages

CSC - 111 - Lab 11

Uploaded by

Muhammad Osama
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

LAB 11

BAHRIA UNIVERSITY KARACHI CAMPUS


Department of Electrical Engineering

INTRODUCTION TO COMPUTING
LAB EXPERIMENT # 11

CONTROL STRUCTURES (IF-ELSE


STATEMENTS)
Objective:-
 To understand and develop programs using if-else.

Theory :-
The C++ language programs presented until now follow a sequential form of execution of
statements. Many times it is required to alter the flow of the sequence of instructions. C++
provides statements that can alter the flow of a sequence of instructions. These statements are
called control statements. These statements help to jump from one part of the program to
another. The control transfer may be conditional or unconditional.

The simplest form of the control statement is the If statement. It is very frequently used in
decision making and allowing the flow of program execution. This lab covers the standard
control structures of a high-level language. Using such control structures require the creation of
simple to complex Boolean statements which evaluate to true or false.

The full if-else statement allows for two-way control. If the value of the expression is true,
statement1 is executed. If the value of the expression equals false, the else option results in
statement2 being executed.

22
LAB 11

Lab Tasks:-

1. Create a C++ program that takes the length and breadth of a shape as input. Using If-Else
structure find out whether the shape is a rectangle or a square. (Hint: if the length and
breadth of the shape are equal, it’s a square. Otherwise it is a rectangle.)

2. A senior salesperson is paid $400 a week; and a junior salesperson is paid $275 a week.
Write a C++ program that accepts as input the salesperson’s status in the character
variable status. If status equals ‘s’, the senior salesperson’s salary should be displayed;
otherwise, the junior person’s salary should be output.

3. Write a program that inputs a character as input and tells whether the entered character is
a vowel or not.

4. In a pass/fail course, a student passes if the marks are greater than or equal to 70 and fails
if the marks are lower. Write a C++ program that accepts marks and prints the message
“A passing grade” or “A failing Grade”, as appropriate.

5. Write a program that takes input the radius of a circle. If this radius is greater than zero,
calculate the area of the circle. If the radius is less than or equal to zero, print an Error
message that area cannot be calculated for negative values.

23

You might also like