+ 1
X=5; Y=++X; Print X; Print Y;
Expecting output. What is the value of X and Y
20 Respostas
0
6 6
+ 6
Sanjay S ,
reading your last post, i am not really sure what your issue or question is. can you please give us some more details?
+ 5
Sanjay S ,
is this a *quiz* or what other purpose does your post have?
+ 5
Sanjay S ,
> the q&a section is for *coding related questions* only. this does *not include quizzes*.
> for promoting codes, quizzes and and other stuff like this, please use the *community* section feed.
+ 3
Hard to say, for example, ++Y can have different meaning by language, not all languages has it or use it. Output printing also differs, some may support comma separator, other needs formatting or string concatenation.
Maybe you could describe the problem in non-programming-language style? what's your doubt actually?
+ 2
In C, C++, Java, C# and several similarly syntactic languages, the pre-increment operator ++(variable) immediately affects its <variable> operand.
Meaning <x> will be incremented by one before its already-incremented-value (6) is assigned to <y>
Had you assigned to <y> using post-increment operator (variable)++ like this ...
int y = x++;
<y> will get original <x> value (5). Value incrementation is not happening yet, value incrementation will take place after the line and the (optional) semicolon (command separator) had been successfully processed / executed.
+ 2
It is 6 and 6
+ 1
Are you sure it's C# code (tagged language - edited)? there's no type definition for the variables. Also C# uses Console.Write() or Console.WriteLine(), not just "Print"
+ 1
Ipang I edited my question please consider the question now.
+ 1
Lothar
Thank you for showing interest.
I am declaring a two variables x and y.
And am intializing a x with value 5 and am assigning a preincrement value of x to y.
So now am printing a x and y now to console.
What is the value of x and y will get
+ 1
Ipang Thank you
+ 1
X= 5 ,y=6 .....Maybe
+ 1
Sanjay S Just run the code in Code Playground and you'll see the output of any code you want
+ 1
The final output will be
6&6
+ 1
6 & 6
0
Sorry it is not C# code.
Irrespective of specific coding language syntax I want answer
0
Like quiz only
0
w = input ("выберите действие; '+' '-' '/' '*': ")
y = input ("введите первое число: ")
x = input ("введите первое число")
if w = "+":
a = y + x
print ("результат: " + str(a))
elif w = w = "-":
a = y - x
print ("результат: " + str(a))
elif w = w = "/":
a = y / x
print ("результат: " + str(a))
elif w = w = "*":
a = y * x
print ("результат: " + str(a))
else:
print ("некорректно введены данные")
input ()
0
I am read a
html