C程式設計》試題

2022-11-25 14:33:05 字數 2082 閱讀 2990

內蒙古機電職業技術學院< 高階語言程式設計 > 試卷

一、 概念題 (每小題4分)

1 試寫出數學式的c語言表示式 .

2 設有如下定義 int x = 6;

執行語句 ; 後請寫出 x 的值 .

3. 設有如下定義 int x = 5, y = 6;

請寫出: 如下程式段執行後的輸出結果 .

printf("==== %d ",(( ++x == y++ )||(x = 8))? --x : --y ) ;

printf("### %d, %d\n", x, y

4. 請寫出: 如下程式段執行後的輸出結果

int a; a = -1;

a = a | 0377; printf(「 %d %o \n」, a, a );

5. 設有定義 char st[80], i, c;

今要求將字串 「this is a string.」 完整記錄於 st中, 試問如下四種輸入方法中,

哪些方法能達到這個要求.

a. gets( st

b. scanf( 「 %20s 」, st );

c. for( i=0; i<16; ist[i]=getchar(); st[i]=』\0』;

d. i=0; while( ( c = getcharn』 ) st[i++] = c; st[i]=』\0』;

6 請寫出: 如下程式段執行後的輸出結果

char *alpha[5] = ;

char **p = alpha; int i = 0;

while ( i < 4 ) printf( 「%c 」, *( *(p+i++)+1 ) );

7. 設有定義 int a[4] = , *p;

請寫出: 如下程式段執行後的輸出結果 .

p = &a[2];

printf("*--p %d\n", *--p

printf("*p++ %d\n", *p

printf("++(*p) %d\n", ++(*p

printf("%d %d %d %d\n",a[0],a[1],a[2],a[3

8. 設有定義 struct date

2。[程式2.2]

int d=1;

func2 ( int p )

static int d=4;

d += p++;

printf("--- p= %d d= %d ", p, d

main

int i, a=5

for(i=0; i<2; i++)

func2 (a);

d += a++;

printf("=== a= %d d= %d\n", a, d); }

}3.[程式2.3

main()

char a[10]="abcd", b[10]="12345678";

int i, j=1;

for(i=3; b[i-1]!='\0'; i++)

a[i]=b[i-1]; a[--i]='\0

printf(" result [1puts(a

while ( a[j++] != '\0' ) b[j]=a[j

printf(" result [2] "); puts(b

4.[程式2.4]

double func4 ( double d, int n )

return ( n ? d*func4 ( d, n -1 ): 1.0 );

main()

double x, w; int n;

x = 6.0;

w = func4 ( x, 4 );

printf("x= %lf ", x);

printf("w= %lf\n", w);

5.[程式2.5]

void func5 ( int *a, int n );

main

int i = 0

static int ab[8] =

C語言程式設計模擬試題

說明 1.本卷共四大題,共7頁.2.本試卷時間120分鐘,滿分100分.1.一 單項選擇題 每題1分,共20分,每小題只有乙個正確答案,請將你認為正確的答案填在對應的括號內。1.以下程式段中i最後的值是 int i 10 switch i 1 a 11 b 13 c 12 d 14 2.若x是int...

C 面試題 C 基礎程式設計題

case 8 cout auguest break case 9 cout september break case 10 cout october break case 11 cout november break case 12 cout december break cout 29.22.程式...

C語言程式設計》複習二試題

廣播電視大學 c語言程式設計a 期末考試試題 2009年1月 一 單項選擇題 每小題2分,共20分 1 由c語言目標檔案連線而成的可執行檔案的預設擴充套件名為 b a cppa b exe c obj d c 2 設有兩條語句為 int a 12 a a a 則執行結束後,a的值為 c a 12 b...