0
Please explain this đ
#include <iostream> using namespace std; int main() { int a[3]={2,7,3}; for (int i=0;i<3;i++){ a[i]-=i; } cout <<a[1]; return 0; }
4 Answers
+ 1
Can you please explain a[1]=a[1]-1
+ 1
a[1] equals to 7. a[1]=a[1]-1 is the same as a[1]=7-1.
7-1 equals to 6. That means, that a[1] is getting the value 6.
0
answer is 6
EXPLANATION:
First we made an array and gave values to it. Now using for loop we change the values stored in the array. As a[i]-=i is equivalent to a[i] = a[i] - i. So when i =1, its a[1]=a[1]-1 ( a[1]=7-1) which comes out to be 6.
hope this helped!!
0
its normal algebra.
like if x =7 and we write x = x - 1. similarly a[1] is 7 and we are changing its value by that algebraic expression.
did this help?