C++ Program to Initialize an Array and Print it

Write C++ Program to Initialize an Array and Print it

// CPP Program to Initialize an Array and Print it

#include <iostream>

using namespace std;

int main()
{
	int A[] = {1, 2, 3, 4, 5}, i, j;

	int B[5];
	B[0] = 88;
	B[1] = 77;
	B[2] = 99;
	B[3] = 55;
	B[4] = 66;

	cout << "Elements of Array A :--> ";
	for(i = 0; i < 5; i++)
	{
		cout << A[i] << " ";
	}

	cout << endl;
	cout << "Elements of Array B :--> ";
	for(i = 0; i < 5; i++)
	{
		cout << B[i] << " ";
	}
	return 0;
}

Output:

Elements of Array A :--> 1  2  3  4  5
Elements of Array B :--> 88  77  99  55  66

≪ Previous | Next ≫