in Technology by
Are the expressions *++ptr and ++*ptr same?

1 Answer

0 votes
by

Both expressions are different. Let’s see a sample code to understand the difference between both expressions.

#include <stdio.h>
int main(void)
{
int aiData[5] = {100,200,300,400,500};
int *piData = aiData;
++*piData;
printf("aiData[0] = %d, aiData[1] = %d, *piData = %d", aiData[0], aiData[1], *piData);
return 0;
}

Output: 101 , 200 , 101

Explanation:
In the above example, two operators are involved and both have the same precedence with a right to left associativity. So the above expression ++*p is equivalent to ++ (*p). In another word, we can say it is pre-increment of value and output is 101, 200, 101.

#include <stdio.h>
int main(void)
{
int aiData[5] = {100,200,30,40,50};
int *piData = aiData;
*++piData;
printf("aiData[0] = %d, aiData[1] = %d, *piData = %d", aiData[0], aiData[1], *piData);
return 0;
}

Related questions

0 votes
    Are the expressions *ptr ++ and ++*ptr same ?...
asked Jan 22, 2021 in Technology by JackTerrance
0 votes
    Explain the difference between *ptr++ and ++*ptr same?...
asked Jan 23, 2021 in Technology by JackTerrance
0 votes
    ‘ptr’ is a pointer to a data type. The expression *ptr++ is evaluated as?...
asked Jan 23, 2021 in Technology by JackTerrance
0 votes
    ______________ are JS functions that you can call from your templates, and encourage you to reuse code and build complex templates a)Expressions b)Helpers c)Template d)Context...
asked Apr 29, 2021 in Technology by JackTerrance
0 votes
    What are the values of the following Python expressions? 2**(3**2) (2**3)**2 2**3**2 a) 512, 64, 512 b) 512, 512, 512 c) 64, 512, 64 d) 64, 64, 64...
asked Dec 31, 2022 in Technology by JackTerrance
0 votes
    What are regular expressions in Cucumber?...
asked Nov 16, 2020 in Technology by JackTerrance
0 votes
    How are Angular expressions different from JavaScript expressions?...
asked Jun 30, 2021 in Education by JackTerrance
0 votes
    Templates can contain HTML and text, mixed with Handlebars expressions. (1)True (2)False...
asked Aug 24, 2021 in Technology by JackTerrance
0 votes
    Which process makes two different Logical expressions look identical? Unification Lifting Inference Process None of the above...
asked Mar 8, 2021 in Technology by JackTerrance
0 votes
    B. Evaluate the following expressions separately in Java. Assume all variable to beintegers and initial values of a as 10 ... /b % b; Select the correct answer from above options...
asked Nov 27, 2021 in Education by JackTerrance
0 votes
    Regular expressions can be thought of as a combination of literals and metacharacters. (a) True (b) False I ... -in-Data-Science,Data-Science-Lifecycle,Applications-of-Data-Science...
asked Oct 30, 2021 in Education by JackTerrance
0 votes
    How can I check a regular expression to be fulfilled only if there is a number or group of numbers ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 27, 2022 in Education by JackTerrance
0 votes
    How can I check a regular expression to be fulfilled only if there is a number or group of numbers ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I am trying to create some user defined forms in our ERP system with an Oracle Database. I have ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 24, 2022 in Education by JackTerrance
...