Write down the output of the following code int array 7 sum 0-02384
This subjective question is related to the book/course vu mth718 Topics in Numerical Methods. It can also be found in vu mth718 Mid Term Solved Past Paper No. 10.
Question 1: Write down the output of the following code?
int array[7], sum = 0;
for(int i=0;i<7;i++){
array[i] = i;
sum+= array[i];
}
cout<< " Sum = " <<sum;
int array[7], sum = 0;
for(int i=0;i<7;i++){
array[i] = i;
sum+= array[i];
}
cout<< " Sum = " <<sum;
Answer:
Loop will run times starts from zero and add values from 1 to 6 which is equal to 21