Math, asked by geekyboy134, 10 months ago

.
Wnat will be the output of the following C code ?
int x=-5, y = 10;
if(x>y)
if (x <0)x=x*-1;
else x=2*x;
else x + = 3*x;
(A) -20
(B) -10
(C) -15
(D) -5
S()​

Answers

Answered by itzyaro7
5

\huge\mathfrak\red{Answer}

• May be -15 is the answer of your question.


geekyboy134: it's -20 but how to solve this ?
itzyaro7: hiii ☺
itzyaro7: hn
Answered by InnerWorkings
0

Answer:

-20

Step-by-step explanation:

Since x is not greater than y it will not go to the first bigger if loop.

It will go to the last else state which says

x = x+ 3x

ie x = -5+3×-5

= -20

Hope this helps you


geekyboy134: can you please tell me how did that x+ = 3*x became x= x+3x ?
InnerWorkings: In C, for example, if you want to say x becomes x+1, you write x+ = 1
InnerWorkings: It is same as writing x=x+1
geekyboy134: Thank you so much
InnerWorkings: Welcome!
geekyboy134: Bro
geekyboy134: I've another question pls check it out
InnerWorkings: Ok I will try
geekyboy134: It will be in my profile maybe
InnerWorkings: ok
Similar questions