C Programming: If Else

更新於 發佈於 閱讀時間約 1 分鐘

Exercise 1: Even or odd

Prompt the user to enter an integer. Determine whether a given number is even or odd


Exercise 2: Grading System

Write a program that takes a student's score as input and prints their corresponding grade based on the following grading scale:

90 and above: A

80 - 89: B

70 - 79: C

60 - 69: D

Below 60: F


Exercise 3: Calculator Program

Write a simple calculator program that takes two numbers and an operator (+, -, *, /) as input and performs the corresponding arithmetic operation.


Code Examples:


avatar-img
3會員
5內容數
留言0
查看全部
avatar-img
發表第一個留言支持創作者!
你可能也想看
Google News 追蹤
Thumbnail
在創作的路上真的很多人問我說 到底要怎麼做出符合自己期待 但又可以表現得很有美感的作品?🥹 這個問題真的應該是每個創作者都一直在學習的課題吧!
提問的內容越是清晰,強者、聰明人越能在短時間內做判斷、給出精準的建議,他們會對你產生「好印象」,認定你是「積極」的人,有機會、好人脈會不自覺地想引薦給你
Thumbnail
num1 = int(input("請輸入第一個數字: ")) num2 = int(input("請輸入第二個數字: ")) if num1 > num2: print(f"{num1} 比 {num2} 大") elif num1 < num2: print(f"{
Thumbnail
題目敘述 Integer to English Words 給定一個整數num 請轉換成對應的的英文數字表達(One, Two, Three, ... 那種數字表達式)
Thumbnail
這篇內容,將會講解什麼是「if else」,以及與「if else」相關的知識。包括if else的簡介、if、if else、else if、套娃式的if。
Thumbnail
IF,Switch,三元運算子語法說明 IF條件選擇結構說明 IF為布林條件,當()內條件式滿足True執行if區塊的程式碼,不滿足則執行else區塊的程式碼,若無else也行。
Thumbnail
在創作的路上真的很多人問我說 到底要怎麼做出符合自己期待 但又可以表現得很有美感的作品?🥹 這個問題真的應該是每個創作者都一直在學習的課題吧!
提問的內容越是清晰,強者、聰明人越能在短時間內做判斷、給出精準的建議,他們會對你產生「好印象」,認定你是「積極」的人,有機會、好人脈會不自覺地想引薦給你
Thumbnail
num1 = int(input("請輸入第一個數字: ")) num2 = int(input("請輸入第二個數字: ")) if num1 > num2: print(f"{num1} 比 {num2} 大") elif num1 < num2: print(f"{
Thumbnail
題目敘述 Integer to English Words 給定一個整數num 請轉換成對應的的英文數字表達(One, Two, Three, ... 那種數字表達式)
Thumbnail
這篇內容,將會講解什麼是「if else」,以及與「if else」相關的知識。包括if else的簡介、if、if else、else if、套娃式的if。
Thumbnail
IF,Switch,三元運算子語法說明 IF條件選擇結構說明 IF為布林條件,當()內條件式滿足True執行if區塊的程式碼,不滿足則執行else區塊的程式碼,若無else也行。