c++
write the code and the flowchart
Name:
CE-100 Introduction to Computer Systems
Tutorial 5 – Decision Structures (Nested decision structures, Logical operators)
OBJECTIVES:
1. Learn how to use nested decision structures in C++ programs
2. Learn the if-else-if ladder structure, in particular.
3. Understand the Boolean operators and their use in Boolean expressions.
RULES:
Hand write your answers, both flowchart and code, on a separate sheet of paper.
it is recommended to use pencil for drawing flowcharts.
Assignment Problems:
Draw the flowchart and write C++ code to solve the following problems (Q1, Q2)
Q1. Input a KCST ID (10 digits). Based on its first 2 digits, display the following message:
First 2 digits of ID Message to print
16 You enrolled in 2016
17 You enrolled in 2017
18 You enrolled in 2018
19 You enrolled in 2019
otherwise Invalid ID
Hint: a regular C++ int is large enough to fit any valid KCST ID.
Q2. Input three integer numbers. Print the smallest one. If two or more numbers are equal,
print: “some are equal”
Q3. What is the output of this program?
#include
using namespace std;
int main() {
int a, b, c;
a = 9; b = 5; c = 2;
if (a < b)
if (a < c) cout << a;
else
cout << c;
else
if (b < c)
cout << b; else
cout << c;
return 0;
}