Cplab 4 Up
Cplab 4 Up
Cplab 4 Up
Objective(s):
1. To be able to apply Loops in C++
2. To be able to apply While Loop in C++
3. To be able to apply For Loop in C++
4. To be able to apply Do-While Loop in C++
5. To be able to apply Pretest and Post-test loop
6. To be able to apply Event and Counter Controlled Loop
Exercises
Exercise 1
Write a program to find the sum of first n Natural Numbers Positive integers such as 1, 2, 3……
n are known as natural numbers using for loop.
Exercise 2
Write a program in C++ that takes input from user repeatedly and calculates sum of those inputs
(only positive numbers) until a negative number is entered then displays the total sum calculated.
Write the program using While Loop.
Exercise 3
Write a program in C++ that takes input from user repeatedly and calculates sum of those inputs
(only positive numbers) until a negative number is entered then displays the total sum calculated.
Write the program using do-While Loop.
Exercise 4
1/2
s CSL-113: Computer Programming Lab
xxxxx
xx
xx
xx
xx
Exercise 5
Exercise 6
Write a program that receives start value and end value then displays series of numbers from
start to end value inclusive. Use do while to make sure user input smallest value first.
2/2