Professional Documents
Culture Documents
CS-114 Report - 3
CS-114 Report - 3
CS-114 Report - 3
Programming
Task 01:
Prompt the user to enter two numbers separately. Write a program to interchange
(i.e. swap) the content of variables in which they were stored. Show the original and
swapped numbers on console. The console window should be intuitive. Add proper
comments to the code. How many different ways can you think of doing this task?
This question may be programmed using the method shown below in which a
temporary variable is introduced to store values during the swapping process.
However, the temporary variable can be removed with the following code and
have the same result.
Code 1
2
Output 1
Task 02:
Write a program that asks the user to enter a three-digit number, and then
prints the sum of its digits. Attempt to build the logic of program completely
by yourself.
Code 2
Output 2
3
Task 03:
Write a program to check if the character entered by the user is a lowercase letter or
an uppercase letter. Once identified, your program should convert it into the
corresponding letter to the other category (i.e. ‘e’ should be converted to ‘E’ and
vice versa). Make the console window intuitive. Attach outputs of both cases.
Code 3
Output 3i
Output 3ii
4
Task 04:
Write a C++ program to check whether an alphabet entered by user is a
vowel or a consonant; using switch statement. Which other statement can be
used instead of switch? How?
Code 4
Output 4i
Output 4ii
5
Task 05:
Write a program that takes an input of the number of runs scored and balls
faced by a batsman over 5 matches. Now calculate the average of batsman
after these 5 matches and the individual strike rate of each match. Your
console should be readable and understandable. Comment complete code.
Code 5
6
Output 5
Task 06:
Write a program that asks the user to input a two-digit number (i.e. from 10-
99), then prints the English word for the number. Make use of switch
statement.
Output 6i
Output 6ii
Code 6v
Code 6iv