籬落疏疏一徑深——2021/1/31
阿新 • • 發佈:2021-02-02
技術標籤:練習
籬落疏疏一徑深
1.函式若無返回值,則它一定無形參。請問這個說法是正確的嗎?
答:這個說法不正確。一個函式可以有引數,沒有返回值;
可以沒有引數,有返回值;可以沒引數,沒返回值;
可以有引數,有返回值。引數和返回值沒有必然聯絡。
2.在下列的符號常量定義中,正確的定義格式為( )。
A.#define M1 B.const int M2 20 C.#define M3 10 D.const char mark
正確答案: C
解析:用 #define 定義識別符號的一般形式為:#define 識別符號 常量 //注意, 最後沒有分號
然後,const int M2 = 20;
//定義常量要有初值。
*3.已知ch是字元變數,下面正確的表示式是()
A.ch=‘120’ B.ch=’\xFF’ C.ch=’\08’ D.ch=’\’
正確答案: B
解析:該題考察的是 char型別的賦值。
4.下述程式的執行結果為( )。
#include<stdio.h>
void abc(char* str)
{
int a, b;
for (a = b = 0; str[a] != '\0'; a++)
{
if (str[a] != 'c')
{
str[b++] = str[a];
}
}
str[b] = '\0';
}
int main()
{
char str[] = "abcdef";
abc(str);
printf("str[]=%s", str);
}
答:程式的執行結果為:str[]=abdef。