Solution for Exercise 7-7
ex0707
#include <stdio.h>
int main()
{
char a,b,c,d;
a = 'W';
b = a + 24;
c = b + 8;
d = '\n';
printf("%c%c%c%c",a,b,c,d);
return(0);
}
Notes
* The math performed on the char variables manipulates the values stored in those variables. A char variable stores a value, an int. That int value represents an ASCII character code. That code is displayed as a character when the %c placeholder is used in printf(), or when sending the value to standard output via the putchar() function.
* Internally, the compiler sees a character constant, such as 'W' as an immediate value. The 'W' format is merely a shortcut the compiler allows for your benefit. (That's sweet.)
* Remember that the number of conversion characters used in a printf() statement must match the number of variables present.
Copyright © 1997-2025 by QPBC.
All rights reserved
