Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Brothers and sisters, help solve the problem! Programming, read two characters into c 1 and c2 with getchar function, and then use putchar and printf functions respectively.
Brothers and sisters, help solve the problem! Programming, read two characters into c 1 and c2 with getchar function, and then use putchar and printf functions respectively.
Hello, I read your topic requirements.

1. Both can be used, because both variables C 1 and C2 can store the ASCII value of the input character, whether it is defined as character char or integer int.

We should use printf function. We know that putchar only outputs characters, so we can use printf("%d%d ",c 1, C2); The ASCII value of the output variable.

It can't be replaced unconditionally. First of all, the two types occupy different memory sizes. Char takes up 1 byte, and int usually takes up 4 bytes. If you need to store large integers, you can only use int type, otherwise there will be overflow problems. So we should decide which type to use according to the specific situation.