printf is used to print formatted output to the console, whereas sprintf is used to store the formatted output as a string in a character array.