Assignment-Level3
Assignment-Level3
2. Write a program that calculates the sum of numbers from 1 to 100 and display the average.
Output:
Sum = 5050
Average = 50.5
3. Write a program that prints all even numbers between 1 and 50.
Output:
2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50
6. Write a program that prints numbers from 1 to 10, but skips multiples of 3.
Output:
1, 2, 4, 5, 7, 8, 10
7. Write a program that calculates the sum of even numbers between 1 and 50.
Sum of even numbers: 650
8. Write a program that prints a countdown from 10 to 1.
Output:
10 9 8 7 6 5 4 3 2 1
10. Write a program that prints a pattern of numbers in an inverted pyramid shape.
Sample output:
Enter a number: 5
12345
1234
123
12
1
11. Write a program that calculates and displays the sum of all numbers between two specified
numbers.
Enter 1st #: 2
Enter 2nd #: 8
Sum is 25
13. Write a program that prints the sum of all digits of a given number.
Sample Output:
Enter a number: 12345
Sum is 15
14. Write a program that prints the odd numbers in a given number.
Sample output:
Enter a number: 34587
Odd numbers: 3, 5, 7