// create and initialize an array of 4 boxes of integers
int a[4];
a[0] = 3;
a[3] = 5;
a[2] = 15;
a[1]= a[0]+a[3];
cout << "a[0] = " << a[0] << "\n";
cout << "a[1] = " << a[1] << "\n";
cout << "a[2] = " << a[2] << "\n";
cout << "a[3] = " << a[3] << "\n";
// create and initialize an array of 4 boxes of integers
int a[4];
// fill the array with values entered by user
for (int i=0; i<=3; i++)
cout <<"Enter value for box a[" << i+1 << "]";
cin >> a[i];
// print the array values from top down
for (int i=0; i<=3; i++)
{ cout << "a[" << i << "] = " << a[i] << "\n";
cout << "----------------\n";
// print the array values from down to top
for (int i=3; i>=0; i--)
{ cout << "a[" << i << "] = " << a[i] << "\n";
Enter value for box a[1]1
Enter value for box a[2]2
Enter value for box a[3]3
Enter value for box a[4]4
a[0] = 1
a[1] = 2
a[2] = 3
a[3] = 4
----------------
a[3] = 4
a[2] = 3
a[1] = 2
a[0] = 1
// create and initialize an array of 4 boxes of integers
float Quiz1[3];
float Quiz2[3];
// fill Quiz1 array with values entered by user
cout << "Enter grades of students on Quiz1\n";
for (int i=0; i<=2; i++)
{
cout <<"Enter value for box a[" << i+1 << "]";
cin >> Quiz1[i];
// fill Quiz2 array with values entered by user
cout << "Enter grades of students on Quiz2\n";
for (int i=0; i<=2; i++)
cout <<"Enter value for box a[" << i+1 << "]";
cin >> Quiz2[i];
nter value for box a[1]50
Enter value for box a[2]60
Enter value for box a[3]70
Enter grades of students on Quiz2
Enter value for box a[1]80
Enter value for box a[2]90
Enter value for box a[3]100
Student [1] Grades on Q1 and Q2: 50 80
Student [2] Grades on Q1 and Q2: 60 90
Student [3] Grades on Q1 and Q2: 70 10
// fill and print array
float test[4] = {50, 60, 70, 80};
for (int i = 0; i <= 3; i++)
cout << "test " << i << " grade is : " << test[i] << endl;
test 0 grade is : 50
test 1 grade is : 60
test 2 grade is : 70
test 3 grade is : 80
// search how many times a target vcalue appeared in the array
const int size =4;
int counter =0, target;
float a[size] = {1, 5, 1, 3};
cout << "Enter target : ";
cin >> target;
for (int i = 0; i < size; i++)
if (a[i] == target)
counter++;
cout << "Target appeared " << counter << " times in the array\n";
Enter target : 1
Target appeared 2 times in the array
Enter target : 8
Target appeared 0 times in the array
// find minimum value in the array
const int size =4;
float a[size] = {2, 5, 1, 3};
int min=a[0];
for (int i = 0; i < size; i++)
if (a[i] < min)
min = a[i];
cout << "Minimum value of the array is " << min << "\n";
// find minimum value and maximum values in the array
const int size =4;
float a[size] = {2, 5, 1, 3};
int max=a[0];
int min=a[0];
for (int i = 0; i < size; i++)
if (a[i] < min)
min = a[i];
if (a[i] > max)
max = a[i];
cout << "Minimum value of the array is " << min << "\n";
cout << "Maximum value of the array is " << max << "\n";
Minimum value of the array is 1
Maximum value of the array is 5