- 相關(guān)推薦
中興c語言筆試題
導(dǎo)語:C語言在編程語言中具有舉足輕重的地位,不少企業(yè)對(duì)員工要求會(huì)c語言,好比華為、中興……,通常他們會(huì)要求筆試,比較他們的理論水平。對(duì)于有意向的學(xué)生、社工來說,提前了解下他們的筆試能為你在求職上帶來助力。下面是小編收集的中興c語言筆試題,希望能為你帶來幫助。
一、請(qǐng)?zhí)顚態(tài)OOL , float, 指針變量 與“零值”比較的 if 語句。(10分)
提示:這里“零值”可以是0, 0.0 , FALSE或者“空指針”。例如 int 變量 n 與“零值”比較的 if 語句為:
if ( n == 0 )
if ( n != 0 )
以此類推。
請(qǐng)寫出 BOOL flag 與“零值”比較的 if 語句:
請(qǐng)寫出 float x 與“零值”比較的 if 語句:
請(qǐng)寫出 char *p 與“零值”比較的 if 語句:
二、以下為Windows NT下的32位C++程序,請(qǐng)計(jì)算sizeof的值(10分)
char str[] = “Hello” ;
char *p = str ;
int n = 10;
請(qǐng)計(jì)算
sizeof (str ) =
sizeof ( p ) =
sizeof ( n ) =
void Func ( char str[100])
{
請(qǐng)計(jì)算
sizeof( str ) =
}
void *p = malloc( 100 );
請(qǐng)計(jì)算
sizeof ( p ) =
三、簡答題(25分)
1、頭文件中的 ifndef/define/endif 干什么用?
2、#include
3、const 有什么用途?(請(qǐng)至少說明兩種)
4、在C++ 程序中調(diào)用被 C編譯器編譯后的函數(shù),為什么要加 extern “C”聲明?
5、請(qǐng)簡述以下兩個(gè)for循環(huán)的優(yōu)缺點(diǎn)
// 第一個(gè)
for (i=0; i<n; p="" i++)<="">
{
if (condition)
DoSomething();
else
DoOtherthing();
}
// 第二個(gè)
if (condition)
{
for (i=0; i<n; p="" i++)<="">
DoSomething();
}
else
{
for (i=0; i<n; p="" i++)<="">
DoOtherthing();
}
優(yōu)點(diǎn):
缺點(diǎn):
優(yōu)點(diǎn):
缺點(diǎn):
四、有關(guān)內(nèi)存的思考題(20分)
void GetMemory(char *p)
{
p = (char *)malloc(100);
}
void Test(void)
{
char *str = NULL;
GetMemory(str);
strcpy(str, "hello world");
printf(str);
}
請(qǐng)問運(yùn)行Test函數(shù)會(huì)有什么樣的結(jié)果?
答:
char *GetMemory(void)
{
char p[] = "hello world";
return p;
}
void Test(void)
{
char *str = NULL;
str = GetMemory();
printf(str);
}
請(qǐng)問運(yùn)行Test函數(shù)會(huì)有什么樣的結(jié)果?
答:
Void GetMemory2(char **p, int num)
{
*p = (char *)malloc(num);
}
void Test(void)
{
char *str = NULL;
GetMemory(&str, 100);
strcpy(str, "hello");
printf(str);
}
請(qǐng)問運(yùn)行Test函數(shù)會(huì)有什么樣的結(jié)果?
答:
void Test(void)
{
char *str = (char *) malloc(100);
strcpy(str, “hello”);
free(str);
if(str != NULL)
{
strcpy(str, “world”);
printf(str);
}
}
請(qǐng)問運(yùn)行Test函數(shù)會(huì)有什么樣的結(jié)果?
答:
【中興c語言筆試題】相關(guān)文章:
基礎(chǔ)C++/C語言筆試題分享11-21
中興通訊南京筆試題02-18
2017年c語言面試筆試題11-22
中興筆試+面試題目11-21
普天C++筆試題02-18
中興09天津硬件筆試題目分享11-21
群碩筆試題Java和C++、C#11-21
中興面試筆試10-26
C++工程師筆試題目11-25