ConvertDec_to_Hex-Oct-Bin.c

ConvertDec_to_Hex-Oct-Bin.c is a simple conversion program that prompts the user for their name, followed by a prompt for an integer from 1 to 1,000,000 (or "x" to exit the program). The integer entered will be displayed in hexadecimal, octal, and binary representation. Conversions must be computed algorithmically (i.e. NOT accomplished via format specifier). The user is then asked if the output should be saved to a text file. If user replies in the affirmative, a name for the text file is requested. The newly created text file will contain the user's name, current date, and output results (see example below).

User Interface:

nter your name: Hal Greenwald
Enter an Integer ( 1 – 1000000) or type x to exit: 240

Decimal: 240
Hexadecimal: F0
Octal: 360
Binary: 11110000

Save to a file? (y/n): y

Enter file name: cs222_hw3.txt

File saved.

Good bye!

Terminal output: see image.

User defined functions:
As a minimum, include the following 2 user-defined functions:

char *getDateAndTime();
Returns a character string with the current date and time

int getInteger()
Read user input into a character string using fgets().
"x" returns -1 to exit program.
Otherwise, convert the string into an integer (which will be returned to main()) using
int atoi(const char *str);
or
int sscanf(const char *s, const char *format, ...);

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.