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
Answer 1:
Output:
Explanation:
In the above program, we did not use loop condition, if we do not use loop condition in the for loop, then the condition will be considered as true in C#, that's why it will print "Hello" infinite times on the console screen.
Answer 2:
Output:
Explanation:
In the above program, we did not use "loop condition" in the "while" loop, that's why the above program will generate a syntax error.
Answer 3:
Output:
Explanation:
The above program will generate syntax error because missed semicolon after loop condition, the correct code is given below:
Answer 4:
Output:
Explanation:
In the above program, we created integer num initialized with 5439, and we also created an implicitly typed variable var which is initialized with 0. Here, loop will execute until the value of variable num is greater than 0.
In the body of the loop, we divide the variable num by 10 and assigned it to the same.
Now look iterations:
Iteration1:
num=5439 and var=0
num = 5439/10;
num = 543;
And we increased the value of "var" then it becomes 1.
Iteration3:
num=54 and var=2
num = 54/10;
num = 5;
And we increased the value of "var" then it becomes 3.
Iteration4:
num=5 and var=3
num = 5/10;
num = 0;
And we increased the value of "var" then it becomes 4. After that loop will terminate because the condition will false.
Answer 5:
Output:
Explanation:
In the above program, we created three integer variables num, ok, res initialized with 153, 0, and 0.
Let's understand the while loop using iterations:
Iteration1: num=153, ok=0, res=0 Loop condition is true. ok = 153%10 = 3; num = 153/10 = 15; res = 0 + (3*3*3) = 27; Iteration2: num=15, ok=3, res=27 Loop condition is true. ok = 15%10 = 5; num = 15/10 = 1; res = 27 + (5*5*5) = 27+125= 152; Iteration3: num=1, ok=5, res=152 Loop condition is true. ok = 1%10 = 1; num = 1/10 = 0; res = 152 + (1*1*1) = 152+1= 153;
Now the condition will true and the loop will terminate and then print 153 on the console screen.
need an explanation for this answer? contact us directly to get an explanation for this answer