Professional Documents
Culture Documents
1. Define a one-dimensional array (size 10) using for loop(s). The program should:
a. Have a predefined array
b. Display the numbers in FIFO and LIFO patterns
#include<iostream>
using namespace std;
void main()
{
int a[10] = { 1,2,3,4,5,6,7,8,9,10 };
cout << " Numbers from 10 to 1 and from 1 to 10 : " << endl;
for (int i = 0; i <= 9; i++)
{
cout << a[i] << "\t";
}
cout << endl;
for (int j = 9; j >= 0; j--)
{
cout << a[j] << "\t";
}
cout << endl;
system("pause");
}
2. Define a two-dimensional array (size 4 x 4) using nested for loops. The program
should:
a. Have a predefined array
b. Display the result in the 4x4 format
c. Also display the transpose (4x4 format)
#include<iostream>
using namespace std;
void main()
{
int a[4][4] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 };
#include<iostream>
using namespace std;
void main()
{
int a[10], m1 = 0, m2 = 0, m3 = 0;
#include<iostream>
using namespace std;
void main()
{
int a[4][4];
for (int i = 0; i < 4; i++)
{