Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need help to convert C++ to C. Can you please includethe function of each import

ID: 3610374 • Letter: N

Question

need help to convert C++ to C. Can you please includethe function of each important code in the comment.

#include<iostream>                      

using namespace std;

void perfect(int num){

int sum=0,i;
   int fact[100],index=0;
    for(i=1; i<num; i++)
    {
        if( (num % i) ==0)       //a number i is a factor ofa number num
       {                        //if i divides into num with no remainder
           sum +=i;            //if its a factor add it with the other factors
           fact[index++]=i;      //save factor
        }
    }
  

    if(sum ==num)              //if the sum of the factors is num
    {
       cout<<num<<": factors(";         //it isperfect
       for(i=0;i<index;i++)             //so print the factors
           cout<<fact[i]<<" ";
       cout<<")"<<endl;
    }
  

    return;


}


int main(){

    int input;
    cout<<"The perfect numbers between 1 and10000 are: ";
    for(input=1;input<=10000;input++)   
         perfect(input);
    system("pause");
    return 0;
}

Explanation / Answer

#include<stdio.h>
#include<conio.h>
void perfect(int num){

int sum=0,i;
   int fact[100],index=0;
    for(i=1; i<num; i++)
    {
        if( (num % i) ==0)       //a number i is a factor ofa number num
       {                        //if i divides into num with no remainder
           sum +=i;            //if its a factor add it with the other factors
           fact[index++]=i;      //save factor
        }
    }
   

    if(sum==num)              //if the sum of the factors is num
    {
        printf("%d: factors(",num);         //it isperfect
       for(i=0;i<index;i++)             //so print the factors
           printf("%d ",fact[i]);
        printf(") ");
          }
   

   return;


}


int main(){

    intinput;
    printf("The perfect numbers between 1 and 10000are: ");
   for(input=1;input<=10000;input++)   
         perfect(input);
    getch();
    return 0;
}