follow instructions below i need a simple code plus comments to explain what u did. simple codes please
ConvertDec_to_Hex-Oct-Bin.c
ConvertDec_to_Hex-Oct-Bin.c is a simple conversion program that prompts the user
for their name and the current date, followed by a prompt for an integer from 1 to
1,000,000. The integer entered will be displayed in hexadecimal, octal, and binary
representation. Conversions must be computed algorithmically (i.e. NOT
accomplished via format specifiers ). 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:
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.
Enter an Integer ( 1 – 1000000) or type x to exit: x
Good bye!
Terminal output:
$cat cs222_hw3.txt
Hal Greenwald
Today’s date and time: Tues Oct 2
3:49:30 2018
Decimal: 240
Hexadecimal: F0
Octal: 360
Binary: 11110000
User defined functions:
As a minimum, include the following 2 user-defined functions:
(prototypes may vary as long as the function works properly)
char *getDateAndTime();
Returns a character string with the current date and time
int getInteger
Read user input into a character string.
“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, …);
Rubric 10 points:
Is the source code well formatted using clearly readable indentation and
white space (while viewed within vi)? 2 points
.
Is the source code well documented with comments? 1 point
.
Error (validation) checking on ALL user input? 1 point
Is the User Interface clear and working properly? 1 point
char *getDateAndTime() implemented correctly? 1 point
int getInteger(char *str_array) implemented correctly? 1 point
Are the conversions correct? 2 points
.
Is the file output correct? 1 point
Submit via Blackboard by Nov 2, 11:59 PM.
1 point will be deducted for each day past the due date.