Senior C language programmers test of the 16 they had the best answer to explain topics + (1)
[Reply from the blog - dishening testing adhere to the following agreement:
â—† assume that all procedures must be the first correct documents have been included.
Consider the following data types:
â—† char for a byte
â—† int for four bytes
â—† long int to four bytes
â—† float for the 4 bytes
â—† double for the 8-byte
â—† long double to 8 bytes
â—† pointer for the four bytes
1 Consider the following program:
# 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);
)
The output for this program is:
(A) 3
(B) 5
(C) 0
(D) None of the above
2, Consider the following program:
Main ()
(
Struct node
(
Int a;
Int b;
Int c;
);
Struct node s = (3, 5, 6);
Struct node * pt = &s;
Printf ( "% d", * (int *) pt);
)
The output for this program is:
(A) 3
(B) 5
(C) 6
(D) 7
3 Consider the following code segment:
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 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
4, Consider the following program:
Main ()
(
Int a [5] = () 1,2,3,4,5;
Int * ptr = (int *) (& a +1);
Printf ( "% d% d", * (a +1), * (ptr-1));
)
The output for this program is:
(A) 2 2
(B) 2 1
(C) 2 5
(D) None of the above
5 Consider the following program:
Void foo (int [] [3]);
Main ()
(
Int a [3] [3] = ((1,2,3), (4,5,6), (7,8,9));
Foo (a);
Printf ( "% d", a [2] [1]);
)
Void foo (int b [] [3])
(
B + +;
B [1] [1] = 9;
)
The output for this program is:
(A) 8
(B) 9
(C) 7
(D) None of the above
6, Consider the following program:
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 for this program is:
(A) c = d = 3
(B) c = 5 d = 3
(C) c = d = 5
(D) 5 d = c = 5
7, Consider the following program:
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]);
)
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
8 Consider following function:
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 are likely to cause problem with pointers
(A) Only f3
(B) Only f1 and f3
(C) Only f1 and f2
(D) f1, f2, f3
9, Consider the following program:
Main ()
(
Int i = 3;
Int j;
J = sizeof (+ + i + + + i);
Printf ( "i =% dj =% d", i, j);
)
The output for this program is:
(A) 4 i = j = 2
(B) i = j = 2
(C) i = j = 4
(D) 3 i = j = 6
10 Consider the following program:
Void f1 (int *, int);
Void f2 (int *, int);
Void (* p [2]) (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);
)
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 for this program is:
(A) 5 5 5 5
(B) 3 5 3 5
(C) 5 3 5 3
(D) 3 3 3 3
11 Consider the following program:
Void e (int);
Main ()
(
Int a;
A = 3;
E (a);
)
Void e (int n)
(
If (n> 0)
(
E (- n);
Printf ( "% d", n);
E (- n);
)
)
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
12, Consider following declaration
Typedef int (* test) (* float, float *)
Test tmp;
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
13 Consider the following program:
Main ()
(
Char * p;
Char buf [10] = (1,2,3,4,5,6,9,8);
P = (buf +1) [5];
Printf ( "% d", p);
)
The output for this program is:
(A) 5
(B) 6
(C) 9
(D) None of the above
14 Consider the following program:
Void f (char **);
Main ()
(
Char * argv [] = ( "ab" and "cd," "ef", "gh", "ij", "kl");
F (argv);
)
Void f (char ** p)
(
Char * t;
T = (p + = sizeof (int)) [-1];
Printf ( "% s", t);
)
The output for this program is:
(A) ab
(B) cd
(C) ef
(D) gh
15 Consider the following program:
# 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 for this program is:
(A) 7
(B) 6
(C) 5
(D) 3
16 Consider the following program:
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 at the end of the execution of the this program is:
(A) 10
(B) 15
(C) 6
(D) 7
Tags: java language






