Hello guys, the question is:
Generate code to declare an integer array,Int_Var, of size 100 and write a C++ Program to carry out the following steps:
a) Assign each array element an initial value of 0;
b) Using a loop to give the first five array elements the following values: Int_Var[0]=0;
Int_Var[1]=1; Int_Var[2]=2; Int_Var[3]=3; Int_Var[4]=4.
c) Using a loop to determine the values for each integer to be beginning from the array element Int_Var[4]:
Array element Int_Var[4];
Int_Var[i]=Int_Var[i-1] + Int_Var[i-2];
And this the code, Can you please confirm it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
#include<iostream>
int int_Var[100]; //global variable
void main(void) {
for(int i = 0; i <= 100;i++){ // Array initialization
int_Var[i] = 0;
}
for (int ii = 0; ii<= 4;ii++){ //assigning the value 0-4 in the array
int_Var[ii] = ii;
}
for(int y = 4; y<= 100; y++){ // Output the value of the array
int value ;
value = int_Var[y];
cout<<"The Value of the Array beginning from array index 4 is :"<<" "<<value<<"\n";
}
}
|
Can you please correct it for me as it is not being compiled. There is an error that I don't know where. And can you please tell me if this code answers the question perfectly.
The error I get is:
error C2065: 'cout' : undeclared identifier
Thanks in advance