mirror of
https://github.moeyy.xyz/https://github.com/TheAlgorithms/C.git
synced 2023-10-11 15:56:24 +08: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
|
* @brief Octal to hexadecimal conversion by scanning user input
|
||||||
* @details
|
* @details
|
||||||
* The octalToHexadecimal function take the octal number as long
|
* The octalToHexadecimal function take the octal number as long
|
||||||
@ -30,6 +31,7 @@ long octalToDecimal(long octalValue){
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Convert octal number to hexadecimal number
|
* @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
|
* @param octalValue is the octal number that needs to be converted
|
||||||
* @returns a hexadecimal value as a string after conversion
|
* @returns a hexadecimal value as a string after conversion
|
||||||
*/
|
*/
|
||||||
@ -60,13 +62,18 @@ int main()
|
|||||||
// execute the tests
|
// execute the tests
|
||||||
test();
|
test();
|
||||||
|
|
||||||
|
// get the value of octal number as input
|
||||||
int octalValue;
|
int octalValue;
|
||||||
printf("Enter an octal number: ");
|
printf("Enter an octal number: ");
|
||||||
scanf("%d", &octalValue);
|
scanf("%d", &octalValue);
|
||||||
|
|
||||||
// Calling the function octalToHexadecimal
|
// call the function octalToHexadecimal and print the hexadecimal value
|
||||||
char *hexadecimalValue = octalToHexadecimal(octalValue);
|
char *hexadecimalValue = octalToHexadecimal(octalValue);
|
||||||
printf("Equivalent hexadecimal number is: %s", hexadecimalValue);
|
printf("Equivalent hexadecimal number is: %s", hexadecimalValue);
|
||||||
|
|
||||||
|
// free the memory allocated dynamically in function octalToHexadecimal
|
||||||
free(hexadecimalValue);
|
free(hexadecimalValue);
|
||||||
|
|
||||||
|
// return 0 and exit
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user