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

Lab Sheet 3

The document outlines programming problems and patterns to solve using loops. It contains two parts, with Part A asking to write programs to output various patterns using loops and a menu-driven calculator program. Part B asks to write programs to calculate powers, count positive/negative/zero numbers, find min/max numbers, and output additional patterns using loops.

Uploaded by

Imaya Senuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Lab Sheet 3

The document outlines programming problems and patterns to solve using loops. It contains two parts, with Part A asking to write programs to output various patterns using loops and a menu-driven calculator program. Part B asks to write programs to calculate powers, count positive/negative/zero numbers, find min/max numbers, and output additional patterns using loops.

Uploaded by

Imaya Senuri
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

CMP120130

Object Oriented Modeling and Development


PART A
1. Write programs to output the following patterns using for/ while loops.

a. b.

* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *

c. d.

* 1 1 1 1 1
* * 2 2 2 2 2
* * * 3 3 3 3 3
* * * * 4 4 4 4 4
* * * * * 5 5 5 5 5

e.

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

2. Write a program to calculate the sum of digits of a given number using a while loop.
3. Write a program to calculate and print the sum of all even numbers from 1 to 50 using a
loop.
4. Write a program to print reverse alphabets from Z to A.
5. Create a menu-driven calculator that performs addition, subtraction, multiplication, and
division based on user input. Use a loop to repeatedly prompt the user for calculations
until they choose to exit.
PART B
1. Write a program to find the value of one number raised to the power of another.
2. Write a program to enter the numbers till the user wants and at the end it should display
the count of positive, negative and zeros entered.
3. Write a program to enter the numbers till the user wants and at the end the program
should display the largest and smallest numbers entered.
4. Print the following patterns using a for/ while loops.

a.
*
* * *
* * * * *
* * * * * * *

b.
1
2 3
4 5 6
7 8 9 10

You might also like