static void Main(string[] args) { int i = 1, j; do { for (j = 1; ; j++) { if (j > 2) break; if (i == j) continue; Console.WriteLine(i + " " + j); } i++; } while (i < 3); Console.ReadLine(); }
a)1 2 2 1
b)2 1 1 2
c)1 3 2 1
d)1 1 2 1
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
a
Explanation: for i = 1. When control enters in loop first if condition is checked for where j = 1 and as (j > 2) which is false. Control is now passed to console statement with i = 1 and j = 2. Now, in while condition value of ‘i’ reflected is 2 i.e i = 2 as i++. Since, (i < 3) control again enters in for loop with i = 2 but j = 1 not j = 2 for j++ and hence, again same condition executes for console statement.
Output : 1 2
2 1