include
Consider the following program, written in C:
char *grumble(char *s) {
for (int i=0; s[i]; i++)
if (s[i] >= 'A' && s[i] <= 'Z')
s[i] = s[i] -'A' + 'a';
return s;
}int main() {
char line[] = "Good Question!";
printf("'%s'\n", grumble(line));
}What is the output from this program?
Answer:
‘good question!’
remark:
makes the upper case letter to lower case
My C program contains the declaration:
char c = ‘B’ –‘a’ + ‘c’;
What is the value of variable c?
Answer: ‘D’
'B' = 66 'a' = 97 'c' = 99
char c = ‘B’ –‘a’ + ‘c’;
c = 66 - 97 + 99
c = 68
c = ‘D’