1. Write a C++ program that will create 2D array using random numbers and then show these values.
#include <iostream>
#include <time.h>
using namespace std;
int main()
{
srand(time(NULL));
int twoDimensionalArray[3][4];
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 4; j++)
twoDimensionalArray[i][j] = rand()%101;
}
cout << endl;
for(int i = 0; i < 3; i++)
{
for(int j = 0; j < 4; j++)
cout << twoDimensionalArray[i][j] << " ";
cout << endl;
}
return 0;
}
Comments
Leave a comment