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

Computer Programming Notes - Semester 01 - Bahria

The document provides instructions for 6 tasks involving loops in C++ programming. The tasks include writing programs to find the sum of natural numbers using for loops, sum of positive numbers using while and do-while loops, printing a tree structure using loops, displaying a pyramid pattern using the alphabet, and displaying a series of numbers between a start and end value using do-while loops.

Uploaded by

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

Computer Programming Notes - Semester 01 - Bahria

The document provides instructions for 6 tasks involving loops in C++ programming. The tasks include writing programs to find the sum of natural numbers using for loops, sum of positive numbers using while and do-while loops, printing a tree structure using loops, displaying a pyramid pattern using the alphabet, and displaying a series of numbers between a start and end value using do-while loops.

Uploaded by

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

CSL-113: Computer Programming Lab

Semester : Spring-2022
Lab Engineer : Soomal Fatima

Lab 04: Loops in C++

Task 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.

Task 2:
Take input positive and negative both numbers from the user and Write a program
to find the sum of only positive numbers using while loop.

Task 3:
Take positive input from the user and Write a program to find the sum of only
positive numbers using do-while loop, end program if negative number added.

Task 4:
Write a program to print tree structure by using loop by choice.
x
xx
xxx
xxxx
xxxxx
xx
xx
xx
xx
CSL-113: Computer Programming Lab
Semester : Spring-2022
Lab Engineer : Soomal Fatima
Write a

Task 5:
Write a C++ Program to display the pattern like pyramid using the alphabet.
OUTPUT:

Task 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.

You might also like