State the output for the following:
i. x = (a>b)? a : b; if a = 2, b = 5
ii. x *= y + 5; if x = 2 , y = 2
Answers
Explanation:
Operators in C
Operators are symbol which tells the compiler to perform certain operations on variables. For example, (*) is an operator which is used for multiplying two numbers.
There are different types of operators in C. Let's take a look at each type of them with few examples of each.
Arithmetic Operators
Relational Operators
Increment and Decrement Operators
Logical Operators
Assignment Operators
Required Answer:-
Question 1:
Given that,
→ a = 2 and b = 5
Calculating x...,
→ x = (a > b) ? a : b
→ a > b = 2 > 5
→ a > b = false
→ Therefore, the result of the given expression is false.
So,
→ x = b
→ x = 5
→ Hence, the value of x is 5.
Answer:
- x = 5
Question 2:
Given that,
→ x = 2 and y = 2
Calculating x...,
→ x *= y + 5
→ x *= 2 + 5
→ x *= 7
This means,
→ x = x * 7
→ x = 2 * 7
→ x = 14
→ Hence, the value of x is 14.
Answer:
- x = 14.