Operators

Q1:
Which of the following statements is correct about the C#.NET code snippet given below?
int d; 
d = Convert.ToInt32( !(30 < 20) );

A A value 0 will be assigned to d.

B A value 1 will be assigned to d.

C A value -1 will be assigned to d.

D The code reports an error.

E The code snippet will work correctly if ! is replaced by Not.

ANS:B - A value 1 will be assigned to d.

Sample Program:

bool falseFlag = false;
bool trueFlag = true;

Console.WriteLine('{0} converts to {1}.', falseFlag,
                  Convert.ToInt32(falseFlag));
Console.WriteLine('{0} converts to {1}.', trueFlag,
                  Convert.ToInt32(trueFlag));
The example displays the following output:

       False converts to 0.
       True converts to 1.



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.