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

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Evaluate 3x - x for x = -2 Answer:

Answered: 1 week ago

Question

What is group replacement? Explain with an example. (2-3 lines)

Answered: 1 week ago

Question

6. The cost of the training creates a need to show that it works.

Answered: 1 week ago