Houkibosi 2013. 9. 25. 20:15

1. 다음과 같은 수들이 정의되어 있을 때 값이 다른 Z는?

int a = 1, b = 2, c = 3, d = 4, e = 5, f = 6, g = 7;

 

1. z = d >> a;

2. z = g % e;

3. z = b & b;

4. z = ( c>b ) ? ++b : b;                    o

 

 

 

 

2. 문자형은 1바이트, 포인터형은 2바이트라고 가정한 경우, 정수형 변수 a, b의 값은?

struct NODE

{

struct NODE* next;

char name;

char age;

} node[3];

 

a = sizeof(struct NODE);

b = sizeof(node);

 

1. a = 3, b = 4

2. a = 3,b = 12

3. a = 4, b = 3

4. a = 4, b = 12                        o

 

 

 

3. 다음의 변수 선언 방법 중 바르지 못한 것을 고르시오.

1. char a = '\\';

2. long int b = 0L;

3. unsigned int c = 0;

4. unsigned float d = 0.0F;                        o

 

 

 

 

 

4. 구조체 변수가 다음과 같이 선언되어 있는 경우 보기의 연산 중 나머지와 다른 것은?

struct point

{

int x;

int y;

};

 

struct rect

{

struct point pt1;

struct point pt2;

};

 

1. p.pt1.x

2. rp->pt1.x

3. r.(pt1->x)                        o

4. (rp->pt1).x

 

 

 

 

5. 다음 프로그램이 실행된 이루 출력되는 값으로 맞는 것은?

int data[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

int *pi;

int t, n;

 

t = 0;

pi = data;

 

for( n = 0; n < 10; n++)

t = t + *p++;

 

printf("%d", t);

 

1. 10

2. 36

3. 45                        o

4. 55

 

 

 

6. 다음의 프로그램과 다른 결과를 내는 프로그램은?

for( n = 0; n < 10; n++)

if( n % 2 == 1) printf("홀수\n");

 

1. n = 0;

while( n < 10 )

{

if( n % 2 == 1 ) printf("홀수\n");

n++;

}

 

2. n = 0;

for( ; n < 10; )

{

if( n % 2 ) printf("홀수\n");

n++;

}

 

3. n = 0;                            o

while( n < 10 )

{

if( n % 2 == 1 ) printf("홀수\n");

else contunue;

n++;

}

 

4. n = 0;

for( ; n < 10; n++ )

{

if( n % 2 == 1 ) printf("홀수\n");

else continue;

}

 

 

 

 

 

7. 다음 프로그램의 수행 결과는?

#include<stdio.h>

 

int func(int n); 

 

void main()

{

int n = 4;

 

printf("%d", func(n));

}

 

int func(int n)

{

if(n == 1) return 1;

return n + func(n-1);

}

 

1. 10                    o

2. 15

3. 20

4. 24

 

 

 

 

8. 다음 프로그램의 수행 결과는?

#include <stdio.h>

 

void main()

{

char* s1 = "CPQtest";

char* dest = (char*) malloc(30);

 

copy(s1, dest);

printf("%s", dest);

}

 

void copy(char* s, char* d)

{

for( ; (*d = *s) != 0; ++d, ++s)

}

 

1. CPQ

2. test

3. CPQtest                    o

4. tsetQPC

 

 

 

 

9. 다음 함수에 대하여 func(5)로 호출하는 경우 함수의 반환값은?

int func( int n )

{

int i = 1;

int tot = 1;

 

do{

tot *= i;

i++;

}while( i <= n )

return tot;

}

 

1. 15

2. 24

3. 120                        o

4. 620

 

 

 

 

10. 다음 프로그램의 수행 결과는?

void func(int[][3]);

 

main()

{

int a[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

 

func(a);

printf("%d", a[2][1]);

}

 

void func(int b[][3])

{

++b;

b[1][1]++;

}

 

1. 7

2. 8

3. 9                        o

4. 10