Declares an array of 20 components; initializes list[0] to 4 and list[1] to 7; all other components are initialized to 0.
#include<iostream>
using namespace std;
int main(){
int list[20];
list[0] = 4;
list[1] = 7;
for(int i=2; i<20; i++){
list[i] = 0;
}
cout<<"Printing the elements of the list\n";
for(int i=0; i<20; i++){
cout<<list[i]<<endl;
}
}
Comments
Leave a comment