Formatted Numbers

// Here Is a c++ solution of the problem.

#include
using namespace std;
int length(const char* str){
int count =0;
int i =0;
while(str[i]!=‘\0’){
count++;
i++;
}
return count;
}
int main(){
char number[10];
cin >> number;
// cout << number;
if(length(number)==1 and number[0] == ‘0’ ){
cout << 0;
return 0;
}
int test=0;
while(number[test] == ‘0’){
if(test+1==length(number)){
cout << 0;
return 0;
}
test++;
}
if(length(number)%3==0){
for(int j =1; j<=(length(number)); j++){
cout<<number[j-1];
if(j%3==0 and j!=length(number)){
cout << ‘,’;
}
}
}
else if(length(number)%3==1){
for(int j =1; j<=(length(number)); j++){
cout<<number[j-1];
if(j%3==1 and j!=length(number)){
cout << ‘,’;
}
}
}
else if(length(number)%3==2){
for(int j =1; j<=(length(number)); j++){
cout<<number[j-1];
if(j%3==2 and j!=length(number)){
cout << ‘,’;
}
}
}

}

/* Hey, this is written by Nafim */
#include<stdio.h>
int main()
{
long int a ;
scanf(“%d”, &a);
int arr[1000];
int i = 0;
while(a != 0)
{
int tem = a%10;
arr[i] = tem;
a = a/10;
i++;
}

i = i-1;
for( int j = i ; j>=0 ; j--)
{
    printf("%d",arr[j]);
    
    if(j%3==0 && j!=0)  // second condition last er comman handle er jonno. 
    {
        printf(",");
    }
}

return 0;

}
WHERE IS MY WRONG ?