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 created a variable num with initial value 5.
Now look to the loop iterations:
Iteration1: i=0 , j =0, here loop condition is true It will print 0 Increase the value of 'i' and 'j' Iteration2: i=1 , j =1, here loop condition is true It will print 1 Increase the value of 'i' and 'j' Iteration3: i=2 , j =2, here loop condition is true It will print 4 Increase the value of 'i' and 'j' Iteration4: i=3 , j =3, here loop condition is true It will print 9 Increase the value of 'i' and 'j' Iteration5: i=4 , j =4, here loop condition is true It will print 15 Increase the value of 'i' and 'j'
Now condition will false, because the value i is 5, which is not less than num, and the loop will terminate.
Answer 2:
Output:
Explanation:
The above program will generate multiple errors because we did not use correct syntax in the for loop, which is given below,
for (int i = 0;int j = 0; i < num; i++, j++)
The correct syntax is given below:
for (int i = 0,j = 0; i < num; i++, j++)
Answer 3:
Output:
Explanation:
In the above program, we created a variable num initialized with 5. Here, we used a nested loop, where the outer loop is used for the number of rows printed, And the inner loop will print execute according to the value of i.
For i=1; It will print 1 For i=2; It will print 1 2 For i=3; It will print 1 2 3 For i=4; It will print 1 2 3 4 For i=5; It will print 1 2 3 4 5
Then the loop will terminate.
Answer 4:
Output:
Explanation:
The program will execute infinite time because we used a post decrement operator instead of an increment operator that's why condition will always true and the loop will never terminate.
Answer 5:
Output:
Explanation:
In the above program, we created a variable num initialized with 5. Here, loop will execute 5 times. In the loop body, we used PI property of Math class and typecast it into integer then it will be 3. When value of variable I will 3 then continue statement skip below WriteLine() statement. That's why it will not print '3' on the console screen.
Note: The continue is a skipping statement. It is used to skip, one or more than one statement based on the specified case.
need an explanation for this answer? contact us directly to get an explanation for this answer