Determine how many addition assignment statements are done in the worst case scenario of the following code. Then determine how many multiplication assignment statements are done in the worst case scenario. Assume that all variables are properly declared. y = 1; for (i=1; i<=n;i++) { for (j = 1; j<=n;j++) { x = i + j; x = x * y; } x = y + x; }
Determine how many addition assignment statements are done in the worst case scenario of the following code. Then determine how many multiplication assignment statements are done in the worst case scenario. Assume that all variables are properly declared.
y = 1;
for (i=1; i<=n;i++)
{
for (j = 1; j<=n;j++)
{
x = i + j;
x = x * y;
}
x = y + x;
}
- The question words to know the number of addition assignments and multiplication assignments in the worst-case scenario of the provided code snippet.
The provided code:-
y = 1;
for (i=1; i<=n;i++)
{
for (j = 1; j<=n;j++)
{
x = i + j;
x = x * y;
}
x = y + x;
}
Step by step
Solved in 2 steps