MCQs
Solving the expression l = (b * c) + (r * e) + 10 .While from left to right the parentheses are given preference first.
Step 1 : b * c is evaluated first inside first parentheses.
Step 2 : r * e is evaluated second on right side of first addition symbol .
Step 3 : After evaluating both parentheses 10 is added to value of both.
Output : My name.
{
int x = 10, y = 20;
int res;
x % y == 0 ? y += 10:(x += 10);
Console.WriteLine(res);
}
Compare() used to compare two strings by taking length of strings in considerations.
Wider datatype like int,long takes more time for manipulation of a program.
ASCII value of character 'a' is 65 and ASCII value of string "a is 97. Output: 65,97
How to intialize a string variable and concatenate string using '+' operator. Output:Good Morning Dr.Gupta.
static void Main(string[] args) { int a = 3, b = 5, c = 1; int z = ++b; int y = ++c; b = Convert.ToInt32((Convert.ToBoolean(z)) && (Convert.ToBoolean(y)) || Convert.ToBoolean(Convert.ToInt32(!(++a == b)))); a = Convert.ToInt32(Convert.ToBoolean(c) || Convert.ToBoolean(a--)); Console.WriteLine(++a); Console.WriteLine(++b); Console.WriteLine(c); }
z = 6 as ++b.
y = 2 as ++c.
6 && 2 = 1
(++a == b ) which is false as 4!=6. Now, !(false) = true i.e 1.
So, 1 || 1 = 1. So, b = 1.
Similarly, c = 2 and a = 4.Now, 2 || 4 = 1.
So, a = 1.
Hence ++a = 2,++b = 2, c = 2.
Output : 2, 2, 2
Scope of variable is the area or region within which variable is declared and hence intialized values of different kind. Based, on which operations of different kinds are carried out on that variable declared within that scope. Its value is preserved until and unless scope of that block ({ })is not expired because as soon as scope gets over. Hence, variable value gets expired. Hence, it's inaccessible after it.
'int' is 32 bit signed integer whereas 'uint' is 32 bit unsigned integer .Range of int is larger than uint.So,compiler cannot implicitly convert from larger datatype to smaller datatype.