Computer Science, asked by siddharthasingh15, 8 months ago

please explain this​

Attachments:

Answers

Answered by Anonymous
0

\huge\mathfrak{Answer}

Explanation :-

First of all it is a ternary operator .

1st line :- ( Explaination )

char x = ' A ' \\ that means x equals to capital A or A = x

int m \\ for storing the value in the next line means it will act as a a variable which will be printed at the last of the program

2nd line :- ( Explanation )

m = ( x == ' a ') ? ' A ' : ' a ' ;

( x == ' a ' ) ? // here first x is there which means the capital A will be there in the place of x as in the beginning of the program only it has been said that char x = ' A ' . now there is two equal signs after that small a is there . the function of two equal signs is to equalise both the left hand operator and the right hand operator that means capital A and small a . now there is a question mark after the bracket closes this means that it is capital A equals to small a but in our common sense also it's true that capital A is not equals to small a so both of them are not equal

' A ' : ' a ' \\ now this part is same as the if else if part it means that from the first part we came to know that capital A is not equal to small a therefore the second a or ( ' a ' ) will get printed. Why ? because it is the syntax of a ternary operator that if the given condition within the bracket that is here is capital A equals to small a comes true than the thing next to the question mark will get printed and if it's not then the second one after the : sign will get printed ...

Last line is very easy it prints the value of m in which small a is stored

So now question is that why 97 is printed . It's nothing but the ASCII value of ' a ' ( small a '

Similar questions