當前位置:概念範文網>求職簡歷>筆試題目>

C程式設計筆試題

筆試題目 閱讀(6.45K)

程式設計就是讓計算機為解決某個問題而使用某種程式設計語言編寫程式程式碼,並最終得到相應結果的過程。下面就由本站小編為大家介紹一下C++程式設計筆試題的文章,歡迎閱讀

C程式設計筆試題

C++程式設計筆試題篇1

一、請填寫BOOL , float, 指標變數 與“零值”比較的 if 語句。(10分)

提示:這裡“零值”可以是0, 0.0 , FALSE或者“空指標”。例如 int 變數 n 與“零值”比較的 if 語句為:

if ( n == 0 )

if ( n != 0 )

以此類推。

請寫出 BOOL flag 與“零值”比較的 if 語句:

請寫出 float x 與“零值”比較的 if 語句:

請寫出 char *p 與“零值”比較的 if 語句:

二、以下為Windows NT下的32位C 程式,請計算sizeof的值(10分)

char str = “Hello” ;

char *p = str ;

int n = 10;

請計算

sizeof (str ) =

sizeof ( p ) =

sizeof ( n ) =

void Func ( char str[100])

{

請計算

sizeof( str ) =

}

void *p = malloc( 100 );

請計算

sizeof ( p ) =

C++程式設計筆試題篇2

簡答題(25分)

1、標頭檔案中的 ifndef/define/endif 幹什麼用?

2、#include 和 #include “filename.h” 有什麼區別?

3、const 有什麼用途?(請至少說明兩種)

4、在C 程式中呼叫被 C編譯器編譯後的函式,為什麼要加 extern “C”宣告?

5、請簡述以下兩個for迴圈的優缺點

// 第一個

for (i=0; i

{

if (condition)

DoSomething;

else

DoOtherthing;

}

// 第二個

if (condition)

{

for (i=0; i

DoSomething;

}

else

{

for (i=0; i

DoOtherthing;

}

優點:

缺點:

優點:

缺點:

C++程式設計筆試題篇3

有關記憶體的思考題(20分)

void GetMemory(char *p)

{

p = (char *)malloc(100);

}

void Test(void)

{

char *str = NULL;

GetMemory(str);

strcpy(str, "hello world");

printf(str);

}

請問執行Test函式會有什麼樣的結果?

答:

char *GetMemory(void)

{

char p = "hello world";

return p;

}

void Test(void)

{

char *str = NULL;

str = GetMemory;

printf(str);

}

請問執行Test函式會有什麼樣的結果?

答:

Void GetMemory2(char p, int num)

{

*p = (char *)malloc(num);

}

void Test(void)

{

char *str = NULL;

GetMemory(&str, 100);

strcpy(str, "hello");

printf(str);

}

請問執行Test函式會有什麼樣的結果?

答:

void Test(void)

{

char *str = (char *) malloc(100);

strcpy(str, “hello”);

free(str);

if(str != NULL)

{

strcpy(str, “world”);

printf(str);

}

}

請問執行Test函式會有什麼樣的結果?