0% found this document useful (0 votes)
12 views4 pages

Operator Related Problems

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Operator Related Problems

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Operator Related Problems

(Total 15 questions)
SL Problem statement Difficulty
levels
1. Program that will take two numbers X and Y as inputs, then calculate and print the values *
of their addition, subtraction, multiplication, division (quotient and reminder).

Sample input (X,Y) Sample output


5 10 Addition: 15
Subtraction: -5
Multiplication: 50
Quotient : 0
Reminder: 5
-5 10.5 Addition: 5.5
Subtraction: -15.5
Multiplication: -52.5
Quotient: 0
Reminder: -48

❖ -14 % 3 = -2
❖ -14 % -3 = -2
❖ 14 % -3 = 2

2. Program that will calculate the area of a circle having radius r. *


Area, A = 2 * Pi * r

Sample input (r) Sample output


5 Area: 31.4
10.5 Area: 65.94

3. Program that will take two numbers (a, b) as inputs and compute the value of the equation *
– (Without using math.h)

X = (3.31 * a2 + 2.01 * b3) / (7.16 * b2 + 2.01 * a3)

Sample input (a, b) Sample output


5 10.5 X = 2.315475
100 -250 X = -12.766287

Documentation by Samiha Samrose, Lecturer, CSE Dept, UIU, Dhaka, Bangladesh.


4. Program that will increment and decrement a number X by 1 inside the printf function. (Use **
++ and - - operators)

Sample input(X) Sample output


5 X++ : 5
++X : 6
X- - : 5
--X : 4
-5 X++ : -5
++X : -4
X- - : -5
--X : -6

5. Program that will increment and decrement a number X by Y. (Use += and -= operators) *

Sample input(X,Y) Sample output


5 10 Incremented Value: 10
Decremented Value: -5
-5 5 Incremented Value: 0
Decremented Value: -10

6. Program that will multiply and divide a number X by Y. (Use *= and /= operators) *

Sample input(X,Y) Sample output


56 10 Multiplication: 560
Division: 5
-56 -10 Multiplication: 560
Division: 5

7. Program that will take two numbers as inputs and print the maximum value. **

Sample input (x, y) Sample output


20 100 Max: 100
50 -20 Max: 50

8. Program that will evaluate the following equations - *


X=a–b/3+c*2–1
Y = a – ( b / ( 3 + c ) * 2) - 1
Z = a – ( ( b / 3) + c * 2) - 1

Sample input (a, b, c) Sample output


9 12 3 X = 10
Documentation by Samiha Samrose, Lecturer, CSE Dept, UIU, Dhaka, Bangladesh.
Y=4
Z = -1

9. Program that will take a, b & c as inputs and decide if the statements are True (1) of False **
(0)

a) (𝑎 + 𝑏) ≤ 80
b) ! (𝑎 + 𝑏)
c) 𝑐! = 0

Sample input (a, b, c) Sample output


10 -10 0 a) True
b) True
c) False

10. Program that will take a, b & c as inputs and decide if the statements are True (1) of False ***
(0)

1) (𝑎 + 𝑏) ≤ 80 && 𝑐 ≥ 0
2) (𝑎 − 𝑏) == 0 | | 𝑐! = 0
3) 𝑎! = 𝑏 | | ! (𝑏 < 𝑐) && 𝑐 > 0
4) (𝑎! = 𝑏 | | ! (𝑏 < 𝑐) ) && 𝑐 > 0

Sample input (a, b, c) Sample output


10 -10 0 1) False
2) True
3) True
4) False

11. Program that will take calculate the roots of a quadratic equation (a.x2 + b.x + c = 0) from ***
the formula, (here, dot (.) stands for multiplication) -

−𝑏 ± 𝑠𝑞𝑟𝑡(𝑏 2 − 4. 𝑎. 𝑐)
𝑟𝑜𝑜𝑡 =
2. 𝑎

Sample input (a, b, c) Sample output


2 4 -16 2.00 -4.00
1 2 3 Imaginary

Documentation by Samiha Samrose, Lecturer, CSE Dept, UIU, Dhaka, Bangladesh.


12. Program that will evaluate the equation ***

𝑥
2𝑐𝑜𝑠 2 𝑥 − √3 sin 𝑥 + 𝑙𝑜𝑔
2
; where 1<= x <=180 [No checking needed]

Sample input (x) Sample output


30 1.810066
120 0.778151
180 3.954243

Program that will take a floating point number X as input and evaluate A,B,C where- **
13. A = Value when X is rounded up to the nearest integer
B = Value when X is rounded down to the nearest integer
C = Absolute value of X

Sample input(X) Sample output


10.6 A = 11, B = 10, C = 10.6
-77.9 A = 78, B = 77, C = 77.9

Documentation by Samiha Samrose, Lecturer, CSE Dept, UIU, Dhaka, Bangladesh.

You might also like