Examly題庫立即開始練習
2 類科共用卷
地方政府公務人員四等-電子工程類科地方政府公務人員四等-電信工程類科
計算機概要11223單選題

下列 C 語言程式的執行結果為何? #include<stdio.h> int b = 100; int A(int c) { int a = 10; return a + b + c; } int main() { int a = 30, b = 60; printf("output = %d\n", A(20)); return 0; }

Aoutput = 90
Boutput = 110
Coutput = 130正確答案
Doutput = 150
答案與詳解
C
正確答案
函式 A 使用全域變數 b=100,區域 a=10,加上參數 c=20,結果 130。main 裡的 a、b 是區域變數不影響 A。

為什麼答案是 C

正解:A() 中 a=10(區域)、b=100(全域,因 A 內未定義 b)、c=20(參數),總和 10+100+20=130。

考點:誤用main區域變數考點:作用域誤解考點:全域變數存取考點:無效組合
載入中…

計算機概要 相關題目

想練更多計算機概要考古題?

Examly 收錄 38 萬+ 道歷屆題目,每題都有像這樣的精選詳解。免費下載,立即開練。

Download on theApp Store即將推出Google Play
黑皮