i got this working code

where i built functions and called them

how to transform this code into one main function??

i tried it didnt give me the output i got before

??

Code:

#include<stdio.h>
int is_abundant(int tndex) {
int jndex,sum;
int flag_1;
flag_1=0;
sum=0;
for(jndex=1;jndex<tndex;jndex++){//start abbondence check for first num (tndex)
if (tndex%jndex==0){
sum=sum+jndex;
}
if (tndex<sum){
flag_1=1;
}
}//end abbondence check for first num
return flag_1;
}
void print_if_sum_of_abundants(int n) {
int i;
for( i=1;i*2<=n;++i) {
if(is_abundant(i)&&is_abundant(n-i)) {
printf("%d=%d+%d\n",n,i,(n-i));
i=n+1;
}
}
}
int main() {
int limit;
int i;
printf("enter number:");
scanf("%d",&limit);
for(i=1;i<=limit;++i) {
print_if_sum_of_abundants(i);
}
return 0;
}

know i need to transform all of my program into one "main" function code

i tried to do that but it gives me a very bad output

Code:

#include<stdio.h>
int main() {
int index;
int limit,i;
int flag_1=0;
int flag_2=0;
int jndex,sum;
int number;
printf("enter number:");
scanf("%d",&limit);
for(number=0;number<=limit;++number) {/////////////////////////////////// start main for
for( index=1;index*2<=number;++index) {
///////////////////////////////////////////////////////////abondence check 1
sum=0;
for(jndex=1;jndex<index;jndex++){//start abbondence check for first num (tndex)
if (index%jndex==0){
sum=sum+jndex;
}
if (index<sum){
flag_1=1;
}
}//end abbondence check for first num
/////////////////////////////////////////////////end abondence check 1
///////////////////////////////////////////////////////////abondence check 2
sum=0;
for(jndex=1;jndex<(number-index);jndex++){//start abbondence check for first num (tndex)
if ((number-index)%jndex==0){
sum=sum+jndex;
}
if ((number-index)<sum){
flag_2=1;
}
}//end abbondence check for first num
/////////////////////////////////////////////////end abondence check 2
if((flag_1==1)&&(flag_2==1)) {
printf("%d=%d+%d\n",number,index,(number-index));
index=number+1;
flag_1=0;
flag_2=0;
}
}
} ///////////////////////////////////////////////end main for
return 0;
}