Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
506 views
in Information Technology by (114k points)
closed by
‘ptrdata’ is a pointer to a data type. The expression *ptrdata++ is evaluated as (in C++):
1. *(ptrdata++)
2. (*ptrdata)++
3. *(ptrdata)++
4. Depends on compiler

1 Answer

0 votes
by (113k points)
selected by
 
Best answer
Correct Answer - Option 1 : *(ptrdata++)

Answer: Option 1

Concept:

Precedence of Unary operator - Increment (++)  is greater than Indirection/Dereference Operator(*).

Explanation: 

Consider the Following Example: 

#include <iostream.h>

using namespace std;
int main()
{

int arr[5] = { 1, 5, 10, 15, 20};

int *ptrdata = arr; 
cout << "ptrdata =  " << ptrdata << " and *ptrdata = " << *ptrdata << endl; 
cout << "*ptrdata++ = " << *ptrdata++ << endl; // 1 will be printed and ptrdata will be pointed to next array element
cout << "ptrdata =  " << ptrdata << " and *ptrdata = " << *ptrdata << endl;
}
So in "*ptrdata++" ptrdata will be post incremented as per data type it is pointing to and then Indirection will be performed.

it is same as *(ptrdata++) Given as Option 1. 

Note:

  • (*ptrdata)++ will increment the Array element and ptrdata will point arr[0] only.

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...