Discussion
Which of the statements is correct about the program?
#include <stdio.h>
int main()
{
int i=10;
int *j=&i;
return 0;
}
Answer: C
Correct answer: j is a pointer to an int and stores address of i
The declaration int *j = &i; declares j as a pointer to int and initialises it with the address of i.
The asterisk belongs to the declarator, not to the type specifier - the declaration reads "*j is an int", hence j is a pointer to int. i is an ordinary int and no pointer at all, and j has one level of indirection, not two, which the number of asterisks makes plain.
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