Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899