0
can anyone make me understand the "for" part of this code
//code is for insert values in ar int main() { int i,a[5],no,pos; cout<<"Enter data in array: "; for(i=0;i<5;i++) { cin>>a[i]; } cout<<"\n\nStored Data in array: "; for(i=0;i<5;i++) { cout<<a[i]; } cout<<"\n\nEnter possition number: "; cin>>pos; cout<<"\n\nEnter new number = "; cin>>no; --pos; for(i=5;i>=pos;i--) { a[i+1]=a[i]; a[pos]=no;
1 ответ
0
int "i" starts at 5. while "i" is greater than or equal to "pos". the for loop will do the code and "i" will drop by one each time until "i" is not greater than or equal to "pos".