// Program 1 #include using namespace std; int main () { cout << " i j" < using namespace std; int main () { cout << " i Array[i]" <
//
#include <iostream>
using namespace std;
int main ()
{
cout << " i j" <<endl;
cout << "----------" <<endl;
int Array1[ 5 ]; // Array1 is an array of 5 integers
for ( int i = 0; i < 5; i++ ) // initialize elements of array i to 0
{
Array1[i] = i + 1; // Array1[i] + 1
cout <<"\n "<< i <<" "<< Array1[i] ; // Display i & Array[i]
cout <<"\n";
}
return 0;
}
// Program 2
#include <iostream>
using namespace std;
int main ()
{
cout << " i Array[i]" <<endl;
cout << "----------------" <<endl;
int Array1[ 5 ]; // Array1 is an array of 5 integers
for ( int i = 0; i < 5; i++ ) // initialize elements of array i to 0
{
Array1[i] = i + 1; // Array1[i] + 1
cout <<"\n "<< i <<" "<< Array1[i] ; // Display i & Array[i]
for ( int j = 0; j < 5; j++ )
{
Array1[j] = j + 2;
cout <<"\n "<< j <<" "<< Array1[j] ; // Display j & Array[j]
}
cout <<"\n";
}
return 0;
}
What the different between Program 1 and Program 2?
Step by step
Solved in 3 steps with 2 images