mirror of
https://github.com/TheAlgorithms/C
synced 2024-11-24 22:39:52 +03:00
updated with the suggested changes
This commit is contained in:
parent
4d20fe4465
commit
f2c9fe3ee5
@ -1,4 +1,5 @@
|
||||
/**
|
||||
* @file
|
||||
* @brief Octal to hexadecimal conversion by scanning user input
|
||||
* @details
|
||||
* The octalToHexadecimal function take the octal number as long
|
||||
@ -30,6 +31,7 @@ long octalToDecimal(long octalValue){
|
||||
|
||||
/**
|
||||
* @brief Convert octal number to hexadecimal number
|
||||
* dynamically allocated memory needs to be freed by the calling the function free
|
||||
* @param octalValue is the octal number that needs to be converted
|
||||
* @returns a hexadecimal value as a string after conversion
|
||||
*/
|
||||
@ -60,13 +62,18 @@ int main()
|
||||
// execute the tests
|
||||
test();
|
||||
|
||||
// get the value of octal number as input
|
||||
int octalValue;
|
||||
printf("Enter an octal number: ");
|
||||
scanf("%d", &octalValue);
|
||||
|
||||
// Calling the function octalToHexadecimal
|
||||
// call the function octalToHexadecimal and print the hexadecimal value
|
||||
char *hexadecimalValue = octalToHexadecimal(octalValue);
|
||||
printf("Equivalent hexadecimal number is: %s", hexadecimalValue);
|
||||
|
||||
// free the memory allocated dynamically in function octalToHexadecimal
|
||||
free(hexadecimalValue);
|
||||
|
||||
// return 0 and exit
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user