Discussion
Consider the following C program.
void f(int, short);
void main()
{
int i = 100;
short s = 12;
short *p = &s;
__________ ; // call to f()
}Which one of the following expressions, when placed in the blank above, will NOT result in a type checking error?
Answer: D
The call that type-checks is f(i,*p).
f is declared as taking an int and a short and returning void. \(i\) is an int, and p is a pointer to short, so *p is a short: the arguments match exactly.
The other choices fail. f(s,*s) and f(i,*s) dereference s, which is a short, not a pointer, so *s is a type error. i = f(i,s) has valid arguments but assigns the result of a void function to an int, which is also a type error.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development