+ 2
Hey friends !please explain me this code and say why out put is 23?
include <iostream> using namespace std; int main() { int a[3]={1,2,3}; for(int i=1;i<=2;i++) cout<<a[i]; return 0; } //output is 23 ?
4 Antworten
+ 2
a[0] = 1
a[1] = 2
a[2] = 3
Using for loop you are printing second and third element of array that is a[1] , a[2].
Hope this helps ☺️☺️.
+ 4
This loop will be executed twice only in the first time will print 2 and the second time 3
Clarification:
cout<<a[1]//output:2
cout<<a[2]//output:3
The matrix will begin printing from the second element with the index 1
0
cin>> [i];
0
Array index begin from 0, so you start the loop from the second element.