Kingdom of Saudi Arabia المملكة العربية السعودية
Ministry of Education وزارة التعليم
University of Jeddah جامعة جدّة
College of Science and Computer Engineering
كلية علوم و هندسة الحاسب
CCCS 111 – Introduction to Programming
LAB 3
Topic:
For-while Loop
Total Marks: 1
Student Name: __________________________________
Student ID: _____________________________________
Marks:
Exercise 1 2 Total
Allocated 0.5 0.5 1
Obtained
CLO, PLO 2.2, S2 2.2, S2
CLO Marks:
CLO2.2, S2 Total
Allocated 1 1
Obtained
Kingdom of Saudi Arabia المملكة العربية السعودية
Ministry of Education وزارة التعليم
University of Jeddah جامعة جدّة
College of Science and Computer Engineering
كلية علوم و هندسة الحاسب
Objectives
1 Ability to receive input from keyboard
2 Use the printf statement as an alternative to cout.
3 Ability to use For loop
4 Ability to use Do-while loop
Program 1: [CLO2.2, S2, 0.5 Mark]
• Create a program called CountUpBy5.
• Input: The program should accept a positive integer 𝑛 from the user as input. If the given
input is not a positive input it should prompt the user to retry
• Hint: use a While-loop for this
• Output: The program should then count all numbers from 0 up to 𝑛 that are multiples of 5
and print them out on a single line on the screen.
• Hint: use a For-loop or a While-loop for this
Program 2: [CLO2.2, S2, 0.5 Mark]
• Modify the CountUpBy5 program in Part 1 and call it CountByC to accept another
number C, by which it will count up to n, the second user provided number.
• Obviously, you have to ensure that C is greater than 0.
• C may also be a fraction, and does not need to be am integer.