in Programming in C recategorized by
205 views
4 votes
4 votes

Consider the following pseudocode procedure.

Which of the following best describes procedure mystery?

  1. It returns a list of numbers from 1 to $n$.
  2. It prints every third number from 1 to $n$.
  3. It returns the sum of the numbers from 1 to $\mathrm{n}$.
  4. It returns the sum of the multiples of 3 from 1 to $n$.
in Programming in C recategorized by
205 views

1 comment

In for loop, we are going from 1 to n and in the if condition is true when the number is multiple of  3, inside the if block we are just doing the sum of those values which is multiple of 3.
0
0

1 Answer

3 votes
3 votes
Option (D) is correct. The for loop iterates over the values of c from 1 to n, but the value of temp increases by c only when c is a multiple of 3.
Answer:

Related questions