what is difference between ++(*p) and (*p)++

Answers were Sorted based on User's Feedback



what is difference between ++(*p) and (*p)++..

Answer / umamaheswari

p is a pointer variable which is holding the address of
another variable ,*p indicates the value that stored in
particular address

++(*p)-the value of the particular variable which is stored
in p is first incremented and used by next instruction

(*p)++ -the value of the particular variable which is
stored is executed or used by next instruction as it is
what it was,if it is any looping statement first time the
loop will be executed with the original value while doing
the second looping it is incremented by 1

Is This Answer Correct ?    3 Yes 2 No

what is difference between ++(*p) and (*p)++..

Answer / vint

++(*p) (or) ++*p -> Pre-increment the Value
(*p)++ -> Post-increment the value

*++p -> Increment the Position and then obtain the Value
*p++ (or) *(p++) -> Obtain the Value and then increment the Position

Example:
#include<stdio.h>
void main()
{
char str[10] = "Helyo";
char *p = str;
printf("%c
",++(*p)); // Pre-Increment the Value -> I
printf("%c
",++*p); // Pre-Increment the value -> J
printf("%c
",(*p)++); // Post-Increment the value -> J and increment to K

printf("%c
",*p++); // Post-Increment the position -> K and move to next position i.e. e
printf("%c
",*(p++)); // Post-Increment the position -> e and move to next position i.e. l
printf("%c
",*++p); // Pre-Increment the position and obtain value -> y

}

Is This Answer Correct ?    1 Yes 0 No

what is difference between ++(*p) and (*p)++..

Answer / srinivas

++(*p)as this means the first the addres is increneted and
then address is assgined

*p++ as this mean that the address is assign to it then the
address is incremented

Is This Answer Correct ?    1 Yes 2 No

what is difference between ++(*p) and (*p)++..

Answer / amaresh chandra das

++(*p)-> Here ,increments the address of p
(*p)++ -> Here , Increments the Value of p

Is This Answer Correct ?    5 Yes 9 No

what is difference between ++(*p) and (*p)++..

Answer / sonal

++(*p) it will increase pointer value to one value
(*p)++ will refer to next memory location

Is This Answer Correct ?    1 Yes 5 No

what is difference between ++(*p) and (*p)++..

Answer / pradeep......

Both are same ..................
reult will not differ in both operations....

#include <stdio.h>
#include <stdlib.h>
//#include <ctype.h>
void main()
{
char *ptr="hello";
clrscr();
//++(*ptr);
(*ptr)++;
printf("%s\n",ptr);
getch();
}


check this code..........

Is This Answer Correct ?    1 Yes 8 No

what is difference between ++(*p) and (*p)++..

Answer / savita

++(*p) means address that contained in p is incremented.

(*p)++ in this case since both the operator are unary
operator , so it's priority is from right to left.Hence here
first address that contained in p is incremented & then
gives the value at that address.

Is This Answer Correct ?    0 Yes 8 No

Post New Answer

More C Interview Questions

Which header file should you include if you are to develop a function which can accept variable number of arguments?

0 Answers   TCS, TISL,


What is volatile variable in c with example?

0 Answers  


write a program without using main function?

2 Answers   TCS,


what is the output of the following program? main() { int c[]={2,8,3,4,4,6,7,5}; int j,*p=c,*q=c; for(j=0;j<5;j++) { printf("%d",*c); ++q; } for(j=0;j<5;j++) { printf("%d",*p); ++p; } }

4 Answers  


Explain goto?

0 Answers  






Write a program to enter the name and age. If age>28 then find salary categories. if age<28 then find that you are gaduate or not.

1 Answers  


void main() {int a[5],i,b=16; for(i=0;i<5;i++) a[i]=2*i; f(a,5,b); for(i=0;i<5;i++) printf("\n %d",a[i]); printf("\n %d",b); } f(int *x,int n,int y) { int i; for(i=0;i<n;i++) *(x+i)+=2; y=y+2; }wat r the errors in the prg.and improvise the prg to get o/p.?

2 Answers   TCS,


Struct(s) { int a; long b; } Union (u) {int a; long b; } Print sizeof(s)and sizeof(u) if sizeof(int)=4 and sizeof(long)=4

2 Answers   Mascot,


What is sizeof array in c?

0 Answers  


how to reverse string "Hello World" by using pointers only. Without any temp var

1 Answers  


Just came across this question, felt worth sharing, so here it is I want you to make a C/C++ program that for any positive integer n will print all the positive integers from 1 up to it and then back again! Let's say n=5 I want the program to print: 1 2 3 4 5 4 3 2 1. Too easy you say? Okay then... You can ONLY USE: 1 for loop 1 printf/cout statement 2 integers( i and n) and as many operations you want. NO if statements, NO ternary operators, NO tables, NO pointers, NO functions!

1 Answers  


Why cant I open a file by its explicit path?

0 Answers  


Categories