Professional Documents
Culture Documents
Program:
Output:
4. Write a program to input n positive numbers and print the largest
number.
Program:
Output:
5. Write a program to print n Fibonacci numbers 0,1,1,2,3,5,8,13,21…
Program:
Output:
6. Write a program to input a number and print whether it is a perfect
number.
Program:
Output:
1. Entering 6
2. Entering 25
7. Write a program to input a number and print whether it is a prime
number.
Program:
Output:
8. Write a program to input 3 numbers and print the biggest number
using nested if.
Program:
Output:
9. Write a program to input 2 numbers and an operator and display the
result.
Program:
Output:
10. Write a program to input a character and print whether it is an
upper-case alphabet, lowercase alphabet, a digit, or a special
character.
Program:
Output:
11. Write a program to input name and basic salary of an employee and
find total salary is an allowance as follows is given.
▪ >= 50000 15% of bs
▪ 20000-49999 10% of bs
▪ 10000-19999 5% of bs
▪ < 10000 2% of bs
Program:
Output:
12.Write a program to input a number and print the sum of all off
numbers till the inputted number.
Program:
Output:
13.Write a program to find factorial of a number (5! = 5*4*3*2*1).
Program:
Output:
14.Write a program to input n numbers and find the sum of it.
Program:
Output:
15. 1
12
123
1234
Program:
Output:
16.4321
321
21
1
Program:
Output:
17. A
AB
ABC
Program:
Output:
18. 1
121
12321
1234321
123454321
Program:
Output:
19.Write a program to print all prime numbers less than 100.
Program:
Output:
20. Write a program to input a number and print whether it is odd
or even.
Program:
Output:
Odd-
Even-
21.Write a program to input name of employee and salary. If salary is
more than 20,000 then a 10% increase in salary otherwise 5%
increase. Print name and increased salary.
Program:
Output:
>20000-
<20000-
22. Write a program to input 3 sides of triangle and find the area
using Heron’s formula if sides form a triangle.
Program:
Output:
23. Write a program to input a year and print whether it is a leap
year or not.
Program:
Output:
24. Write a program to input 3 numbers and print the largest
number.
Program:
Output:
25. Write a program to input a number and print the sum of all odd
numbers till the inputted number.
Program:
Output:
26. Write a program to input a number and print the multiplication
table of that number.
Program:
Output:
27. Write a program to find the sum of series:
i.
ii. (Without
pow () and ** operator)
iii.
i. Program:
Output:
ii. Program:
Output:
iii. Program:
Output:
28. Write a program to input a number and print sum of digits.
Program:
Output:
29. Write a program to input a denary number and convert to
binary.
Program:
Output:
30. Write a program to input a binary number and convert to
decimal.
Program:
Output: