C 언어의 기본 수준 을 테스트 해 보 세 요.
C/C++ code
#include<setjmp.h>
static jmp_buf buf;
int main() {
volatile int b;
b =3;
if(setjmp(buf)!=0) {
printf("%d ", b);
exit(0);
}
b=5;
longjmp(buf , 1);
return 0;
}
2,The output for this program is: (a) 3 (b) 5 (c) 6 (d) 7
C/C++ code
struct node {
int a;
int b;
int c;
};
int main() {
struct node s= { 3, 5,6 };
struct node *pt = &s;
printf("%d" , *(int*)pt);
return 0;
}
3,What function of x and n is compute by this code segment? (a) x^n (b) x*n (c) n^x (d) None of the above
C/C++ code
int foo ( int x , int n)
{
int val;
val =1;
if (n>0) {
if (n%2 == 1) val = val *x;
val = val * foo(x*x , n/2);
}
return val;
}
4,The output for this program is: (a) 2 2 (b) 2 1 (c) 2 5 (d) None of the above
C/C++ code
int main() {
int a[5] = {1,2,3,4,5};
int *ptr = (int*)(&a+1);
printf("%d %d" , *(a+1), *(ptr-1) );
return 0;
}
5,The output for this program is: (a) 8 (b) 9 (c) 7 (d) None of the above
C/C++ code
void foo(int [][3] );
int main(){
int a [3][3]= { { 1,2,3} , { 4,5,6},{7,8,9}};
foo(a);
printf("%d" , a[2][1]);
return 0;
}
void foo( int b[][3]) {
++ b;
b[1][1] =9;
}
6,The output for this program is: (a) c=3 d=3 (b) c=5 d=3 (c) c=3 d=5 (d) c=5 d=5
C/C++ code
int main() {
int a, b,c, d;
a=3;
b=5;
c=a,b;
d=(a,b);
printf("c=%d" ,c);
printf("d=%d" ,d);
return 0;
}
7,The output for this program is:(a) 2 3 5 6 (b) 2 3 4 5 (c) 4 5 0 0 (d) None of the above
C/C++ code
int main() {
int a[][3] = { 1,2,3 ,4,5,6};
int (*ptr)[3] =a;
printf("%d %d " ,(*ptr)[1], (*ptr)[2] );
++ptr;
printf("%d %d" ,(*ptr)[1], (*ptr)[2] );
return 0;
}
8,Which of the above three functions are likely to cause problem with pointers (a) Only f3 (b) Only f1 and f3 (c) Only f1 and f2 (d) f1 , f2 ,f3
C/C++ code
int *f1(void) {
int x =10;
return(&x);
}
int *f2(void) {
int*ptr;
*ptr =10;
return ptr;
}
int *f3(void) {
int *ptr;
ptr=(int*) malloc(sizeof(int));
return ptr;
}
9,The output for this program is: (a) i=4 j=2 (b) i=3 j=2 (c) i=3 j=4 (d) i=3 j=6
C/C++ code
int main() {
int i=3;
int j;
j = sizeof(++i+ ++i);
printf("i=%d j=%d", i ,j);
return 0;
}
10,The output for this program is: (a) 5 5 5 5 (b) 3 5 3 5 (c) 5 3 5 3 (d) 3 3 3 3
C/C++ code
void f1(int *, int);
void f2(int *, int);
void(*p[2]) ( int *, int);
int main() {
int a;
int b;
p[0] = f1;
p[1] = f2;
a=3;
b=5;
p[0](&a , b);
printf("%d\t %d\t" , a ,b);
p[1](&a , b);
printf("%d\t %d\t" , a ,b);
return 0;
}
void f1( int* p , int q) {
int tmp;
tmp =*p;
*p = q;
q= tmp;
}
void f2( int* p , int q) {
int tmp;
tmp =*p;
*p = q;
q= tmp;
}
11,The output for this program is: (a) 0 1 2 0 (b) 0 1 2 1 (c) 1 2 0 1 (d) 0 2 1 1
C/C++ code
void e(int );
int main() {
int a;
a=3;
e(a);
return 0;
}
void e(int n) {
if(n>0) {
e(--n);
printf("%d" , n);
e(--n);
}
}
12,type of tmp is (a) Pointer to function of having two arguments that is pointer to float (b) int (c) Pointer to function having two argument that is pointer to float and return int (d) None of the above
C/C++ code
typedef int (*test) ( float * , float*)
test tmp;
13,The output for this program is: (a) 5 (b) 6 (c) 9 (d) None of the above
C/C++ code
int main() {
char *p;
char buf[10] ={ 1,2,3,4,5,6,9,8};
p = &((buf+1)[5]);
printf("%d" , *p);
return 0;
}
14,The output for this program is: (a) ab (b) cd (c) ef (d) gh
C/C++ code
Void f(char**);
int main() {
char * argv[] = { "ab" ,"cd" , "ef" ,"gh", "ij" ,"kl" };
f( argv );
return 0;
}
void f( char **p ) {
char* t;
t= (p+= sizeof(int))[-1];
printf( "%s" , t);
}
15,The output for this program is: (a) 7 (b) 6 (c) 5 (d) 3
C/C++ code
#include<stdarg.h>
int ripple ( int , ...);
int main(){
int num;
num = ripple ( 3, 5,7);
printf( " %d" , num);
return 0;
}
int ripple (int n, ...) {
int i , j;
int k;
va_list p;
k= 0;
j = 1;
va_start( p , n);
for (; j<n; ++j) {
i = va_arg( p , int);
for (; i; i &=i-1 )
++k;
}
return k;
}
16, The value of j at the end of the execution of the this program is: (a) 10 (b) 15 (c) 6 (d) 7
C/C++ code
4. 567913. 답 은 다음 에 첨부 합 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.