C Programming - Pointer to Structures
Question 1
|
What is the output of this C code?
Compile time error
| |
1
| |
Undefined behaviour
| |
false
|
Question 2
|
What is the output of this C code?
Compile time error
| |
1
| |
false
| |
Undefined behaviour
|
Question 3
|
What is the output of this C code?
Compile time error
| |
1
| |
Undefined behaviour
| |
Segmentation fault
|
Question 4
|
What is the output of this C code?
Compile time error
| |
1
| |
Segmentation fault
| |
Undefined behaviour
|
Question 5
|
Which of the following are incorrect syntax for pointer to structure? (Assuming struct temp{int b;}*my_struct;)
*my_struct.b = 10;
| |
(*my_struct).b = 10;
| |
my_struct->b = 10;
| |
Both (a) and (b)
|
Question 6
|
Which of the following is an incorrect syntax to pass by reference a member of a structure in a function? (Assume: struct temp{int a;}s;)
func(&s.a);
| |
func(&(s).a);
| |
func(&(s.a));
| |
None of the mentioned
|
Question 7
|
Which of the following structure declaration doesn’t require pass-by-reference?
struct{int a;}s; main(){}
| |
struct temp{int a;}; main(){ struct temp s; }
| |
struct temp{int a;}; main(){} struct temp s;
| |
None of the mentioned
|
Question 8
|
For the following function call which option is not possible? func(&s.a); //where s is a variable of type struct and a is the member of the struct.
Compiler can access entire structure from the function.
| |
Individual member’s address can be displayed in structure.
| |
Individual member can be passed by reference in a function.
| |
Both (b) and (c).
|
Question 9
|
Comment on the output of this C code?
Output will be 1
| |
Output will be 10
| |
Output varies with machine
| |
Compile time error
|
Question 10
|
What is the output of this C code?
Compile time error
| |
1 5
| |
Undefined behaviour
| |
false
|
Question 11
|
What is the output of this C code?
hello
| |
Run time error
| |
Nothing
| |
Depends on compiler
|
Question 12
|
What is the output of this C code?
hello
| |
Segmentation fault
| |
Run time error
| |
Nothing
|
Question 13
|
What is the output of this C code?
Run time error
| |
Nothing
| |
hello
| |
Varies
|
Question 14
|
What is the output of this C code?
Run time error
| |
Nothing
| |
Varies
| |
hello
|
Question 15
|
What is the output of this C code?
Different address
| |
Run time error
| |
Nothing
| |
Same address
|
Question 16
|
What is the output of this C code?
Compile time error
| |
Segmentation fault/code crash
| |
2
| |
1
|
Question 17
|
What is the output of this C code?
Compile time error
| |
Undefined behaviour
| |
Segmentation fault/code crash
| |
1
|
Question 18
|
What is the output of this C code?
1 5
| |
1 3
| |
Compile time error
| |
1 4
|
Question 19
|
What is the output of this C code?
Compile time error
| |
Undefined behaviour
| |
1 3
| |
1 5
|
Check Your Answers:
1. D
2. C
3. A
4. A
5. A
6. D
7. D
8. A
9. B
10. D
11. A
12. B
13. C
14. D
15. D
16. B
17. B
18. A
19. D
0 comments:
Post a Comment