int arr[4];             for (int i = 0; i<4; i++)                         if (i%2 == 0)                                     arr[i]=2*i;                         else                                     arr[i]=i;   What value is assigned to arr[0]? What value is assigned to arr[1]? What value is assigned to arr[2]? What value is assigned to arr[3]?

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 8SA
icon
Related questions
Question
100%

Refer to the following code segment. show your solution.

 

            int arr[4];

            for (int i = 0; i<4; i++)

                        if (i%2 == 0)

                                    arr[i]=2*i;

                        else

                                    arr[i]=i;

 

  1. What value is assigned to arr[0]?
  2. What value is assigned to arr[1]?
  3. What value is assigned to arr[2]?
  4. What value is assigned to arr[3]?
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning