c++ - Values of array elements remain unchanged -
i new c++. below program converting integer array. value of array not change initialized value.
#include <iostream> #include <algorithm> using namespace std; int main(){ int n,i=0; cin >> n; int arr[100]={0}; while(n){ arr[i]=n%10; i++; n=n/10; cout<<arr[i]; } return 0; }
the value of arr[i]
printed 0
. not understand error. can please tell error.
try increment i
after printing
cout << arr[i] << endl; i++;
Comments
Post a Comment