C# Looping Statements(Engineering > Computer Science And Engineering > C# .net ) Questions and Answers
Explanation:-
Answer: Option A. -> Hi"¦infinite timesfor i = 0 ,if condition is satisfied as (i == 0).So,label statement is printed.
Output : Hi
Question 2. Select output for the following set of code :
static void Main(string[] args) { int i, s = 0, a = 1, d; i = Convert.ToInt32(Console.ReadLine()); do { d = i % (2 * 4); s = s + d * a; }while ((Convert.ToInt32(i = i / (2 * 4))) != 0 && (Convert.ToBoolean(Convert.ToInt32((a) = (a * 10))))); Console.WriteLine(s); Console.ReadLine(); }enter i = 342.
static void Main(string[] args) { int i, s = 0, a = 1, d; i = Convert.ToInt32(Console.ReadLine()); do { d = i % (2 * 4); s = s + d * a; }while ((Convert.ToInt32(i = i / (2 * 4))) != 0 && (Convert.ToBoolean(Convert.ToInt32((a) = (a * 10))))); Console.WriteLine(s); Console.ReadLine(); }enter i = 342.
Explanation:-
Answer: Option B. -> It finds octal equivalent of iNone.
Output : i = 342.
s = 526.
Explanation:-
Answer: Option D. -> Code give output as 55Since occurrence of termination symbol(;) at end of for loop.
Output: 55.
Explanation:-
Answer: Option C. -> Compile time errorKeyword "break is not part of if-else statement.This keyword is used in case of loop or switch case statement.
Explanation:-
Answer: Option B. -> Sachin Tendulkar(0.002 “ 0.1f) not equivalent to zero hence it is true. So,only first if clause will execute and print:Sachin Tendulkar on console.As,first condition is always true so no else if statement will be executed. Output: Sachin Tendulkar
Explanation:-
Answer: Option C. -> 2345Reverse of number using while loop.
Output: 2345.
Explanation:-
Answer: Option C. -> Compile time errorInvalid expression'7:' in case 9:7:.