Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
92 views2 pages

ITC Lab 5.0

This document outlines 6 tasks involving while loops in C++. Task 1 decreases a variable by 0.5 each iteration while it remains positive. Task 2 prints square roots of odd numbers up to 50. Task 3 calculates the factorial of a given number. Task 4 prints different patterns using while loops. Task 5 takes 15 integers from the user and performs an operation they select. Task 6 takes inputs until 'q' is pressed and calculates average and product. Task 8 continuously prompts for the same input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
92 views2 pages

ITC Lab 5.0

This document outlines 6 tasks involving while loops in C++. Task 1 decreases a variable by 0.5 each iteration while it remains positive. Task 2 prints square roots of odd numbers up to 50. Task 3 calculates the factorial of a given number. Task 4 prints different patterns using while loops. Task 5 takes 15 integers from the user and performs an operation they select. Task 6 takes inputs until 'q' is pressed and calculates average and product. Task 8 continuously prompts for the same input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Lab No.

5
While loop

Task No.1
Repeatedly print the value of the variable XYZ, decreasing it by 0.5 each time, as long as XYZ remains
positive.

Task No.2
Print the square roots of the first 50 odd positive integers.

Task No.3
Factorial of any number n is represented by n! and is equal to 1*2*3*....*(n-1)*n. E.g.-
4! = 1*2*3*4 = 24
3! = 3*2*1 = 6
2! = 2*1 = 2
Also,
1! = 1
0! = 0
Write a C++ program to calculate factorial of a number given by user.

Task No.4
Use while loop to print the following patterns.
a.
*
**
***
****
*****
******
*******
********

b.
*
**
****
******
****
**
*
c.
1010101
10101
101
1
Task No.5
Take 15 integers values from user using while loop. Ask the user to decide by taking input from user that
what he wants to perform. Show the following menu to the user
Enter 1 for sum
Enter 2 for average
Enter 3 to find the largest number
Display the results accordingly

Task No.6
Take integer inputs from user until he/she presses q ( Ask to press q to quit after every integer input ).
Print average and product of all numbers.

Task No.8
Drive the user crazy by insisting they re-enter a particular input no matter what they enter. Be creative...

You might also like