You are on page 1of 3

Extra problems Lec(2)

(1) Write a program that reads a positive integer and


checks if it is a perfect square.

(2) Write a program to make a simple calculator using


switch-case. The calculator takes the operation
(+ or – or * or /) and takes the two input arguments and print the
results.

(3) Write a program that takes one character and checks if it


alphabet or not.

(4) Write program that converts any letter from


lowercase to uppercase.

(5) Write a program that reads two integers and checks if the
first is multiple of the second.

(6) Write a program that calculates the required heater


activation time according to the input temperature of water.
- if input temperature is from 0 to 30, then required
heating time = 7 mins.
- if input temperature is from 30 to 60, then required
heating time = 5 mins.
- if input temperature is from 60 to 90, then required
heating time = 3 mins.
- if input temperature is more than 90, then required
heating time = 1 mins.
- if temperature is invalid (more than 100), display
"Invalid input"
Example:
Input = 10 → output = 7
Input = 35 → output = 5

(7) Write a program to add two floating numbers. Determine


the integer floor of the sum. The floor is the truncated float
value, anything after the decimal point is dropped.

(8) Write a program that reads a positive integer and


checks if it is a prime number.

(9) Write a program to display English alphabets from A to Z.

(10) Write a program to calculate the power of a number.


The number and its power are input from user.

(11) Write a program to reverse a number.

(12) Write a program to display half pyramid using stars pattern.


*
**
***
****
*****
(13) Write a program to display inverted half pyramid using
stars pattern.
*****
****
***
**
*
(14) Write a program to display a full pyramid using stars pattern.
*
***
*****
*******
********
(15) Write a program to display cross or X-shape using stars
pattern.
* *
* *
* *
* *
* *
**
**
* *
* *
* *
* *
* *

You might also like