You are on page 1of 2

Lab 8

Programming Fundamentals
Nested Loop and Functions
8.1 Rectangle Shape Asterisk
Aim: To introduce the idea of Nested Loop
Question: Write a C++ program (Task081)) to print the below shape. Use
nested loop. The program should take two integers for length and width
then print the rectangle in Asterisk (*).

Sample run:
Enter length and width: 10 5
**********
**********
**********
**********
**********

8.2 Triangle Shape Numbers


Aim: To introduce the idea of Nested Loop
Question: Write a C++ program (Task082)) to print the below shape. Use
nested loop

Sample run:

22

333

4444

55555

666666

7777777
8. 3 void Function
Aim: To introduce the of user defined functions
Question: Write a C++ program (Task083) to do the following
1-You program accepts two integers from the standard input and calls function
divide to prints the result of dividing the first number by the second.
2-You program accepts 4 integer numbers and calls function print1 to print the
numbers.
3-You program accepts 3 integer numbers and calls function to print2 the average of
numbers

Sample sun:
Enter two numbers: 10 20
Result of 10/20 = 0
Enter four integers: 5 6 12 10
The numbers are: 5 , 6 , 12 , 10
Enter three integers: 15 12 10
Avg = 12.333

You might also like