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

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -