Consider the following code that is contained in the main function of a C program. What is wrong with the code? unsigned int myUnsignedInt = 100; printf("%c\n", myUnsignedInt);
Code:
int myUnsignedInt = 100;
printf("%c\n", myUnsignedInt);
output: d
explanation: here inside using "%c" you trying to print the character whose ASCII value is 100. And character 'd' ASCII value is 100. That's the reason the code output is d.
If you want to print the integer value then use "%d" instead of "%c" inside printf()
Get Answers For Free
Most questions answered within 1 hours.