Professional Documents
Culture Documents
CS 100 Lab 4 Tasks
CS 100 Lab 4 Tasks
Fall 2021-2022
Daim Armaghan
Lab Guidelines
1. You are allowed to perform/submit the lab only during the lab timings
2. Make sure you do not leave the lab without submitting your work on LMS
3. Copying/sharing code is strictly prohibited. Using any unfair means will lead to immediate
disqualification
4. Put all cpp files into a folder YourRollNo_Lab4_TAname and submit it on LMS
(Assignments>Lab4)
5. Lab ends at 8:50 pm and the submission tab closes at the same time
Task1 Total
20
Task2 Total
30
Task3 Total
30
Write a program that asks for your LUMS email address (2xxxxxxx@lums.edu.pk) and
displays the roll number in full form (20xx-xx-xxxx).
Sample Output:
__________________________________________________________________
Write a program that asks user for name, phone number (in format 03xxxxxxxxx) and
date of birth (in format dd/mm/yyyy) and displays a unique code in following format:
name_mm_dd_yyyy_03xxxxxxxxx
________________________________________________________________
Write a program that swaps two letters in a word. It should first ask user to input a
word and then ask the user to input position of character to be replaced. It should
then ask the user to input position of character to replace with. Finally, it displays the
updated word after swapping.
<you are not allowed to use If/else in this task. (-5 marks for violation)>
<positions start from 1>
<Hint: First character has position 1, second character has position 2, and so on>
<for simplicity:
• assume that positions entered by user are valid i.e., in range 1 to length of
word
• input word has at least 2 characters.
• position 1 is less than position 2. (“position of character to be replaced” is less
than “position of character to replace with”)>
<Note: All test Examples given below must pass to get full credit>
Test Examples:
Sample Output:
Enter a word:
rocket
Updated Word:
reckot