221 views

1 Answer

3 3 votes

Initially, $\texttt{count = 0}$.

For $\texttt{i = 1}$:
$\texttt{j = 1}$ gives $\texttt{1 * 1 = 1}$, so add $\texttt{1}$.
$\texttt{j = 2}$ gives $\texttt{1 * 2 = 2}$, so add $\texttt{2}$.
$\texttt{j = 3}$ gives $\texttt{1 * 3 = 3}$, so add $\texttt{3}$.
$\texttt{j = 4}$ gives $\texttt{1 * 4 = 4}$, so add $\texttt{4}$.
Now, $\texttt{count = 10}$.

For $\texttt{i = 2}$:
$\texttt{j = 1}$ gives $\texttt{2 * 1 = 2}$, so add $\texttt{1}$.
$\texttt{j = 2}$ gives $\texttt{2 * 2 = 4}$, so add $\texttt{2}$.
$\texttt{j = 3}$ gives $\texttt{2 * 3 = 6}$, so add $\texttt{3}$.
$\texttt{j = 4}$ gives $\texttt{2 * 4 = 8}$, so $\texttt{break}$ occurs.
Now, $\texttt{count = 10 + 1 + 2 + 3 = 16}$.

For $\texttt{i = 3}$:
$\texttt{j = 1}$ gives $\texttt{3 * 1 = 3}$, so add $\texttt{1}$.
$\texttt{j = 2}$ gives $\texttt{3 * 2 = 6}$, so add $\texttt{2}$.
$\texttt{j = 3}$ gives $\texttt{3 * 3 = 9}$, so $\texttt{break}$ occurs.
Now, $\texttt{count = 19}$.

For $\texttt{i = 4}$:
$\texttt{j = 1}$ gives $\texttt{4 * 1 = 4}$, so add $\texttt{1}$.
$\texttt{j = 2}$ gives $\texttt{4 * 2 = 8}$, so $\texttt{break}$ occurs.
Now, $\texttt{count = 20}$.

Therefore, the output is $\texttt{20}$.

Answer:
Position:
Show:

Related questions

8 8 votes
1 1 answer
235
235 views
GO Classes asked Jun 6
235 views
What is the output of the following code?#include <stdio.h void change(int *p, int *q) { *p = *p + 4; *q = *p + *q; p = q; *p = *p - 3; } int main() { int a = 6, b = 10; ...
8 8 votes
1 1 answer
208
208 views
GO Classes asked Jun 6
208 views
What is the output of the following code?#include <stdio.h int calc(int n) { if (n == 1) return 2; return n + calc(n - 1); } int main() { printf("%d", calc(4)); return 0;...
8 8 votes
1 1 answer
241
241 views
GO Classes asked Jun 6
241 views
What is the output of the following code?#include <stdio.h void fun() { static int x = 3; int y = 2; x = x + y; y = y + x; printf("%d ", x); } int main() { fun(); fun(); ...
8 8 votes
1 1 answer
241
241 views
GO Classes asked Jun 6
241 views
What is the output of the following code?#include <stdio.h int main() { int a = 8, b = 12; int *p = &a; int *q = &b; *p = *p + *q; q = p; *q = *q - 5; printf("%d %d", a, ...