Q:
C#.Net find output programs (Operators) | set 2
belongs to collection: C#.Net find output programs
C#.Net find output programs
- C#.Net find output programs (Data Types) | set 1
- C#.Net find output programs (Data Types) | set 2
- C#.Net find output programs (Data Types) | set 3
- C#.Net find output programs (Operators) | set 1
- C#.Net find output programs (Operators) | set 2
- C#.Net find output programs (Operators) | set 3
- C#.Net find output programs (const Keyword) | set 1
- C#.Net find output programs (this Keyword) | set 1
- C#.Net find output programs (readonly Keyword) | set 1
- C#.Net find output programs (static Keyword) | set 1
- C#.Net find output programs (static Keyword) | set 2
- C#.Net find output programs (if else) | set 1
- C#.Net find output programs (if else) | set 2
- C#.Net find output programs (if else) | set 3
- C#.Net find output programs (switch statement) | set 1
- C#.Net find output programs (switch statement) | set 2
- C#.Net find output programs (switch statement) | set 3
- C#.Net find output programs (goto) | set 1
- C#.Net find output programs (Loops) | set 1
- C#.Net find output programs (Loops) | set 2
- C#.Net find output programs (Loops) | set 3
- C#.Net find output programs (Arrays) | set 1
- C#.Net find output programs (Arrays) | set 2
- C#.Net find output programs (Arrays) | set 3
- C#.Net find output programs (default Arguments) | set 1
- C#.Net find output programs (default Arguments) | set 2
- C#.Net find output programs (Parameter Passing) | set 1
- C#.Net find output programs (Enumeration) | set 1
- C#.Net find output programs (Enumeration) | set 2
- C#.Net find output programs (Boxing & Unboxing) | set 1
- C#.Net find output programs (Structure) | set 1
- C#.Net find output programs (Structure) | set 2
- C#.Net find output programs (Structure) | set 3
- C#.Net find output programs (Classes & Objects) | set 1
- C#.Net find output programs (Classes & Objects) | set 2
- C#.Net find output programs (Classes & Objects) | set 3
- C#.Net find output programs (Constructors & Destructors) | set 1
- C#.Net find output programs (Constructors & Destructors) | set 2
- C#.Net find output programs (Constructors & Destructors) | set 3
- C#.Net find output programs (Inheritance) | set 1
- C#.Net find output programs (Inheritance) | set 2
- C#.Net find output programs (Inheritance) | set 3
- C#.Net find output programs (Interface) | set 1
- C#.Net find output programs (Interface) | set 2
- C#.Net find output programs (Method Overloading) | set 1
- C#.Net find output programs (Method Overloading) | set 2
- C#.Net find output programs (Method Overriding) | set 1
- C#.Net find output programs (Method Overriding) | set 2
- C#.Net find output programs (Method Overriding) | set 3
- C#.Net find output programs (Operator Overloading) | set 1
- C#.Net find output programs (Operator Overloading) | set 2
- C#.Net find output programs (Operator Overloading) | set 3
- C#.Net find output programs (Namespace) | set 1
- C#.Net find output programs (Namespace) | set 2
- C#.Net find output programs (Exception Handling) | set 1
- C#.Net find output programs (Exception Handling) | set 2
- C#.Net find output programs (Exception Handling) | set 3
Answer1:
Output:
Explanation:
The above program will generate syntax error because the relational operator returns boolean values in C#. Here, we used relation operator (==) to check equality.
RES = (A == B);
In the above expression, RES is an integer variable, and here we assigned a boolean value to RES, then it will generate an error.
Answer 2:
Output:
Explanation:
The above program will generate syntax error, because "conditional operator" required LVALUE for assignment and return type of WriteLine() method is void also.
Answer 3:
Output:
Explanation:
In the above program, we created three variables A, B, and ret that are initialized with "3.14F", "3.14", and 0 respectively. Here, data type of A is float and data type of B is double then (A==B) condition will false and 0 assigned to variable ret. So finally "0" will print on the console screen.
Answer 4:
Output:
Explanation:
The above program will print 10 on the console screen. In the above program, we created three variables A, B, and ret that are initialized with "3.14F", "3.14", and 0 respectively.
Let's evaluate the conditional operator,
ret = (A == (float)B) ? sizeof(int)==sizeof(float)?10:20:30;
Here, we typecast B into float type, then (A == (float)B) condition will true then we check below condition,
sizeof(int)==sizeof(float)
The size of int and float is 4 then this condition will true and 10 is assigned to the variable ret.
Then the final value of ret will be printed on the console screen.
Answer 5:
Output:
Explanation:
The above program will generate syntax error because in the below expression, we used assignment operator "=" instead of "equal to" operator "==", that why 20 is assigned to the variable "a", and we know that we cannot apply "&&" operator between int and bool operands.
ret = (a=20)&&(Math.PI==pi);
need an explanation for this answer? contact us directly to get an explanation for this answer