0% found this document useful (0 votes)
3 views

Lab 05

Uploaded by

bba66712
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Lab 05

Uploaded by

bba66712
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Sukkur IBA University Khairpur Campus

PROGRAMMING FUNDAMENTALS
Lab 05: Understanding Switch Case and For loop
Under

Course Programming Fundamentals


Course Code CSC-102
Course Instructor(s) Nadeem Ahmed Tunio
Date (Lab Conducted) 18th September 2023 Date (Lab Submitted)

Objectives of Lab No. 5:


1. Switch Case
2. Operator precedence & type casting
3. Loop (For Loop)

Practice Exercise 01: Predict output of following program.


Practice Exercise 02: Evaluate the folloing expressions.

Practice Exercise 03: A Switch Case Example


Practice Exercise 04: A For loop example: Generate numbers from 1 to 50.

Practice Exercise 05: A For loop example: Finding factorial of given number.
Exercise:
1:

2:

3:
Input two integers and find if they are equal, smaller or greater to eachother.

4:
a. Write a program in C++ using loops to print even numbers from 1 to 100.
b. Write a program in C++ using for loop to print below pattern:
1
1 3
1 3 5
1 3 5 7
5:
A bank in your town updates its customers’ accounts at the end of each month. The bank offerstwo
types of accounts: savings and checking. Every customer must maintain a minimum balance. If a
customer’s balance falls below the minimum balance, there is a service charge of $10.00 for savings
accounts and $25.00 for checking accounts. If the balance at the end of the month is at least the
minimum balance, the account receives interest as follows:

(a) Savings accounts receive 4% interest.

(b) Checking accounts receive 3% interest;

Write a program that reads a customer’s account number (int type), account type (char; s for
savings, c for checking), minimum balance that the account should maintain, and current balance.
The program should then output the account number, account type, current balance, and an
appropriate message. Test your program by running it five times, using the following data:

46728 S 1000 2700


87324 C 1500 7689
79873 S 1000 800
89832 C 2000 3000
98322 C 1000 750
…END…

You might also like