1D Array

PHOTO EMBED

Tue Sep 10 2024 04:47:28 GMT+0000 (Coordinated Universal Time)

Saved by @Rohan@99

#include <iostream>
 using namespace std;
 int main() 
 {
    int num[15];

    cout << "{";

    for(int i = 0; i < 15; i++)
    {
        if(i % 2 == 0)
        {
            num[i] = i * 2;
        }
        else
        {
            num[i] = i * 3;
        }

        cout << num[i] << ", ";
    }

    cout << "}";
 }
content_copyCOPY

Create a 1-D Array of size 15. Initialize values as follow(0-based indexing)- 1. if the index is odd, initialize it with 3*index 2. if the index is even, initialize it with 2*index. Print the array.