C Programming – Character Pointers and Functions
Question 1
|
What is the output of this C code?
hello, world
| |
Crash/segmentation fault
| |
Undefined behaviour
| |
Run time error
|
Question 2
|
What is the output of this C code?
hello world
| |
hello worldg india
| |
Compile time error
| |
Undefined behaviour
|
Question 3
|
What is the output of this C code?
hello, world!!
| |
Compile time error
| |
Undefined behaviour
| |
Segmenation fault
|
Question 4
|
What is the output of this C code?
hello. world
| |
hello, world
| |
Compile error
| |
Segmentation fault
|
Question 5
|
What is the output of this C code?
hello. world
| |
hello, world
| |
Compile error
| |
Segmentation fault
|
Question 6
|
What is the output of this C code?
11 11
| |
12 12
| |
4 12
| |
4 11
|
Question 7
|
What is the output of this C code?
11 11
| |
12 11 .
| |
11 12
| |
x 11 where x can be any positive integer
|
Question 8
|
What is the output of this C code?
l
| |
e
| |
h
| |
o
|
Question 9
|
What is the output of this C code?
hello
| |
Run time error
| |
Nothing
| |
h
|
Question 10
|
Comment on the output of this C code?
Memory holding “this” is cleared at line 3
| |
Memory holding “this” loses its reference at line 3
| |
You cannot assign pointer like in Line 3
| |
Output will be This, Program
|
Question 11
|
What type initialization is needed for the segment “ptr[3] = ’3′;” to work?
char *ptr = “Hello!”;
| |
char ptr[] = “Hello!”;
| |
Both (a) and (b)
| |
None of the mentioned
|
Question 12
|
The syntax for constant pointer to address (i.e., fixed pointer address) is:
const
| |
Both (a) and (c)
|
Question 13
|
Comment on the output of this C code?
Compile time error, declaration of a function inside main.
| |
Compile time error, no definition of function fn_ptr.
| |
Compile time error, illegal application of statement fn_ptr = add.
| |
No Run time error, output is 5.
|
Question 14
|
The correct way to declare and assign a function pointer is done by: (Assuming the function to be assigned is “int multi(int, int);”)
int (*fn_ptr)(int, int) = multi;
| |
int *fn_ptr(int, int) = multi;
| |
int *fn_ptr(int, int) = &multi;
| |
Both (b) & (c)
|
Question 15
|
Calling a function f with a an array variable a[3] where a is an array, is equivalent to
f(a[3])
| |
f(*(a + 3))
| |
f(3[a])
| |
All of the mentioned
|
Question 16
|
What is the output of this C code?
h
| |
e
| |
m
| |
o
|
Question 17
|
What is the output of this C code?
Compile time error
| |
h
| |
e
| |
o
|
Check Your Answers:
1. B
2. A
3. C
4. D
5. A
6. C
7. A
8. B
9. A
10. B
11. B
12. B
13. D
14. A
15. D
16. A
16. A
0 comments:
Post a Comment