Lab-2 Task
Lab-2 Task
Lab – 2
1. Write a script to print number in words using while loop.
2. Print multiplication table of 24, 50 and 29 using for loop with tab formatting.
3. Make guess game using do while loop.
4. Write a script to find first and last digit of any number using while loop.
5. Write a script to count number of digits in an integer using while loop. e.g. 12345 total
integers are 5.
6. Write a script to print all natural numbers in reverse from n to 1 using while loop.
7. Take 10 integers using for loop and print their average value on the screen.
8. Print the following patterns using for loop :
*
**
***
****
9. Print ASCII values and their equivalent characters. ASCII value vary from 0 to 255.
10. Write a C++ program to calculate factorial of a number. Factorial of any number n is
represented by n! and is equal to 1*2*3*....*(n-1)*n. E.g.-
a. 4! = 1*2*3*4 = 24
b. 3! = 3*2*1 = 6
c. 2! = 2*1 = 2
d. Also,
e. 1! = 1
f. 0! = 0
11. Write a program to keep asking for a number until you enter a negative number
using while loop. At the end, print the sum of all entered numbers.
12. Keep ask the name and marks. Tell them their grade value as “Muddassir your
marks are 90 and got A Grade”. if enter any negative value then print invalid
input and exit code. To estimate his grade as follows: “A” if marks are greater
than equal to 90, “B” if marks are greater than equal to 80, “C” if marks are
greater than or equal to 70, “D” if marks are greater than or equal to 60, the
student will be failed otherwise.