167k views
2 votes
Write a statement to declare and initialize an array of int named denominations that contains exactly six elements. Your declaration statement should initialize the elements of the array to the following values: 1, 5, 10, 25, 50, 100. (The value 1 goes into the first element; the value 100 to the last.)

1 Answer

5 votes

Answer:

// here is statement in C++ to declare and initialize an array.

int denominations[]={1, 5, 10, 25, 50, 100};

Step-by-step explanation:

In C++, an array can be declare and initialize in a single statement.Syntax to declare and initialize an array in C++ is type <type> <name>[]={val1,vale2...valn}. Here first literal is type of array and second is name of the array.And in the {} braces value of the array.In the above statement type is integer and name of the array is "denominations" and the values are 1,5,10,25,50,100.

//here is implementation in C++.

// include headers

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// declare and initialize array

int denominations[]={1, 5, 10, 25, 50, 100};

return 0;

}

User Romylussone
by
5.7k points