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 -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -