Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C program to convert numbers between different numbering system. Allow user to choose within decimal, octal, and hexadecimal system. A starting code is

Write a C program to convert numbers between different numbering system. Allow user to choose within decimal, octal, and hexadecimal system.

A starting code is given. You can use it or start with your own design.

Test with different original number systems and desired systems.

#include

#include

void clearInputBuffer(); int main(void)

{ puts("Number Converter");

char userChoiceOriginal = ' ';

char userChoiceDesired = ' ';

int numberToConvert = 0;

puts("Please choose the original number system, d for Decimal, o for Octal, h for Hex:");

scanf("%c", &userChoiceOriginal);

clearInputBuffer();

switch(userChoiceOriginal){ case 'd': printf("Please enter decimal number: ");

scanf("%d", &numberToConvert);

clearInputBuffer();

break;

case 'o': printf("Please enter octal number: ");

scanf("%o", &numberToConvert);

clearInputBuffer();

break;

case 'h': printf("Please enter hexadecimal number: ");

scanf("%x", &numberToConvert);

learInputBuffer();

break;

default: puts("Incorrect input. Bye!");

return 0;

} //Ask for desired output system and then display accordingly

return 1;

}

void clearInputBuffer(){ char ch; while((ch = getchar()) != ' ');

}

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

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

2. Discuss various aspects of the training design process.

Answered: 1 week ago

Question

5. Discuss the key roles for training professionals.

Answered: 1 week ago