Measure the test taker's knowledge about the top ten questions about Embedded C developers.

Source: Internet
Author: User
Very basic questions about the C language, an Information Class (computer, Information Engineering, electronic engineering, communication engineering) graduates should reach the level. It is not difficult to answer questions. All of them can be answered quickly. Of course, a certain amount of knowledge is required.
For most people, we expect that you may get an incorrect answer 3) 4) 15). Therefore, if you get a wrong answer within 3, we think you are great.
Within five wrong answers, we think you are not bad (you may still have 9th wrong answers)
If you have more than six questions that cannot be answered correctly, basically we cannot say anything ....

Conventions:
1) in the following test questions, all the necessary header files have been correctly included
2) Data Type
Char 1 byte
Int two bytes 2 bytes (16-bit system, think integer is 2 bytes)
Long int, four bytes, 4 bytes
Float four bytes 4 byet
Double, eight bytes, 8 bytes
Long double 10 bytes 10 bytes
Pointer two bytes 2 byte (note that the address bus is only 16 bits)

Question 1st: measure the test taker's knowledge about the volatile keyword.

# Include <setjmp. h>
Static jmp_buf Buf;
Main ()
{
Volatile int B;
B = 3;
If (setjmp (BUF )! = 0)
{
Printf ("% d", B );
Exit (0 );
}
B = 5;
Longjmp (BUF, 1 );
}

Excuse me, the output of this program is
(A) 3
(B) 5
(C) 0
(D) None of the above

Question 2nd: Test type conversion

Main ()
{
Struct Node
{
Int;
Int B;
Int C;
};
Struct node S = {3, 5, 6 };
Struct node * PT = & S;
Printf ("% d", * (int *) pt );
}

The output of this program is:
(A) 3
(B) 5
(C) 6
(D) 7

3rd question: Examine recursive calls

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;
}

What functions (Operations) Does this code perform on X and N )?
(A) x ^ n (n power of X)
(B) x * n (the product of x and N)
(C) n ^ x (x power of N)
(D) None of the above

Question 4th: Examine pointers. This question is only suitable for those who are very careful and have a deep understanding of pointers and arrays.

Main ()
{
Int A [5] = {1, 2, 3, 4, 5 };
Int * PTR = (int *) (& A + 1 );
Printf ("% d", * (a + 1), * (ptr-1 ));
}

The output of this program is:

(A) 2 2
(B) 2 1
(C) 2 5
(D) None of the above

Question 5th: multi-dimensional arrays and pointers

Void Foo (INT [] [3]);
Main ()
{
Int A [3] [3] = {1, 2, 3}, {4, 5, 6}, {7, 8, 9 }};
Foo ();
Printf ("% d", a [2] [1]);
}
Void Foo (int B [] [3])
{
+ + B;
B [1] [1] = 9;
}

The output of this program is:

(A) 8
(B) 9
(C) 7
(D) None of the above

6th question: comma-separated expressions

Main ()
{
Int A, B, C, D;
A = 3;
B = 5;
C = A, B;
D = (A, B );
Printf ("c = % d", C );
Printf ("d = % d", d );
}

The output of this program is:

(A) C = 3 D = 3
(B) C = 5 d = 3
(C) C = 3 D = 5
(D) C = 5 d = 5

Question 7th: pointer Array

Main ()
{
Int A [] [3] = {1, 2, 3, 4, 5, 6 };
INT (* PTR) [3] =;
Printf ("% d", (* PTR) [1], (* PTR) [2]);
++ PTR;
Printf ("% d", (* PTR) [1], (* PTR) [2]);
}

The output of this program is:

(A) 2 3 5 6
(B) 2 3 4 5
(C) 4 5 0 0
(D) None of the above

Question 8th: measure the test taker's knowledge about function pointers.

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;
}

Which of the above three functions is most likely to cause pointer problems?

(A) Only F3
(B) Only F1 and F3
(C) Only F1 and F2
(D) F1, F2, F3

9th question: test self-added operations (++)

Main ()
{
Int I = 3;
Int J;
J = sizeof (++ I );
Printf ("I = % d J = % d", I, j );
}

The output of this program is:

(A) I = 4 J = 2
(B) I = 3 J = 2
(C) I = 3 J = 4
(D) I = 3 J = 6

Question 10th: test form parameters, actual parameters, pointers, and Arrays

Void F1 (int *, INT );
Void F2 (int *, INT );
Void (* P [2]) (int *, INT );
Main ()
{
Int;
Int B;
P [0] = F1;
P [1] = F2;
A = 3;
B = 5;
P [0] (& A, B );
Printf ("% d/T", a, B );
P [1] (& A, B );
Printf ("% d/T", a, B );
}
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;
}

The output of this program is:

(A) 5 5 5 5
(B) 3 5 3 5
(C) 5 3 5 3
(D) 3 3 3 3

11th question: test the auto-increment operation (--)

Void E (INT );
Main ()
{
Int;
A = 3;
E ();
}
Void E (int n)
{
If (n> 0)
{
E (-- N );
Printf ("% d", N );
E (-- N );
}
}

The output of this program is:

(A) 0 1 2 0
(B) 0 1 2 1
(C) 1 2 0 1
(D) 0 2 1 1

12th question: test the typedef type definition and function pointer

Typedef int (* test) (float *, float *);
Test TMP;

The TMP type is

(A) pointer to the function. This function uses two pointers pointing to float as parameters (arguments)
Pointer to function of having two arguments that is pointer to float
(B) Integer
(C) pointer to a function. The function uses two pointers pointing to float as parameters (arguments) and the return value type of the function is integer.
Pointer to function having two argument that is pointer to float and return int
(D) None of the above

Question 13th: Differences and relationships between arrays and pointers

Main ()
{
Char P;
Char Buf [10] = {1, 2, 4, 5, 6, 9, 8 };
P = (BUF + 1) [5];
Printf ("% d", P );
}

The output of this program is:

(A) 5
(B) 6
(C) 9
(D) None of the above

Question 14th: Examine the pointer Array

Void F (char **);
Main ()
{
Char * argv [] = {"AB", "cd", "Ef", "GH", "IJ", "Kl "};
F (argv );
}
Void F (char ** P)
{
Char * t;
T = (p + = sizeof (INT) [-1];
Printf ("% s", t );
}

The output of this program is:

(A) AB
(B) CD
(C) EF
(D) GH

Question 15th: This question examines the variable length parameter of C. Just like printf () in the standard function library, this topic is generally not discussed in Chinese university classes, and it will not be excitable,

# Include <stdarg. h>
Int ripple (INT ,...);
Main ()
{
Int num;
Num = ripple (3, 5, 7 );
Printf ("% d", num );
}
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;
}

The output of this program is:

(A) 7
(B) 6
(C) 5
(D) 3

Question 16th: measure the test taker's knowledge about static variables.

Int counter (int I)
{
Static int COUNT = 0;
Count = count + I;
Return (count );
}
Main ()
{
Int I, J;
For (I = 0; I <= 5; I ++)
J = counter (I );
}

The value of J is as follows:

(A) 10
(B) 15
(C) 6
(D) 7

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.