Question: I'm having trouble running and compiling my program Here's my code: #include #include int main(){ int i; int j; int num; char input[10]; int binary[10];

I'm having trouble running and compiling my program

Here's my code:

#include

#include

int main(){

int i;

int j;

int num;

char input[10];

int binary[10];

printf("Starting the CPSC 1011 Decimal to Binary Converter ");

while(1){

i=0;

printf("Please enter a postive whole number(or EOF to quit):" );

scanf("%s", &input); // there's an error here

if(strcmp(input,"")==0){

printf("Thank you for using the CPSC 1011 Decimal to Binary Generator. Goodbye!");

return(0);

}

num=atoi(input); // there's an error here

if(num<=0){

printf("Sorry, that was not a postive whole number.");

printf(" ");

}

else{

int temp=num;

while(num>0){

binary[i]=num%2;

num=(num)/2;

i++;

}

printf("%d (base-10) is equivalent to ", temp);

for(j=i-1; j>=0; j--){

printf("%d",binary[j]);

}

printf(" (base-2)!");

printf(" ");

}

}

return(0);

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!