Previous: 4.7 Summary
Up: 4 Processing Character Data
Next: 4.9 Problems
Previous Page: 4.7 Summary
Next Page: 4.9 Problems
ch = 'd';(a) ((ch >= 'a') && (ch <= 'z')) (b) ((ch > 'A') && (ch < 'Z')) (c) ((ch >= 'A') && (ch <= 'Z')) (d) ch = ch -'a' + 'A'; (e) ch = ch - 'A' + 'a';
char ch;
int d;
ch = 'd';
d = 65;
printf("ch = %c, value = %d\n", ch, ch);
printf("d = %d, d = %c\n", d, d);
'a' to 'z',
'A' to 'Z',
'0' to '9'.
#define SQ(x) ((x) * (x))
#define CUBE(x) ((x) * (x) * (x))
#define DIGITP(c) ((c) >= '0' && (c) <= '9')
char c = '3';
if (DIGITP(c))
printf("%d\n", CUBE(c - '0'));
else
printf("%d\n", SQ(c - '0'));
char c;while (c = getchar()) putchar(c);
#include <stdio.h>
main()
{ int n, sum;
char ch;
ch = 'Y';
sum = 0;
scanf("%d", &n);
while (ch != 'N') {
sum = sum + n;
printf("More numbers? (Y/N) ");
scanf("%c", &ch);
scanf("%d", &n);
}
}