C語言練習題:scanf 輸入(C language exercise: input with scanf )
練習一:大小寫轉換 讓使用者輸入小寫字母,程式轉成大寫字母。 讓使用者輸入大寫字母,程式轉成小寫字母。 Exercise 1: Case converter Take a lowercase letter from the user and convert it to uppercase letter. Take a uppercase letter from the user and convert it to lowercase letter. 練習一參考解法: Exercise 1 solution: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #include <stdio.h> #include <stdlib.h> int main () { char letter, small, large; printf( "Please input a small letter:" ); scanf( " %c" , & small); letter = small + ( 'A' - 'a' ); printf( "Large letter is %c \n " , letter); printf( "Please input a large letter:" ); scanf( " %c" , & large); letter = large + ( 'a' - 'A' ); printf( "Small letter is %c \n " , letter); return 0 ; } 練習二:數學式 輸入4個整數a, b, c, d,求出(a + b) * (c + d)的結果。 Exercise 2: Equation Get four integers a, b, c, d from the user. Calculate (a + b) * (c + d) and ...