Professional Documents
Culture Documents
Lab Sheet 3
Lab Sheet 3
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