演示版本
VS2013
- 判斷字母是否大寫
實例說明:
輸入一個字母,判斷是否為大寫字母。如果是,則提示"uppercase-letter!",否則提示"other-letter!"。
利用if語句判斷輸入字符的ASCII碼是否在65~90這個范圍內,如果在,則該字符是大寫字母;否則不是大寫字母。
#include <stdio.h> #include <math.h> int main() { char c; printf("輸入一個字母:\n"); c = getchar(); if (c >= 65 && c <= 90) printf("uppercase letter!\n"); else printf("other letter!\n"); return 0; }

阿飛
2021年8月6日
