[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.
Interview Questions and Answers :: Broadcom Ltd

2. Write a statement which will increment the pointer value to 10 on doing ptr++
int arr[100];
int *ptr;
/* do something here*/
ptr++; // This should incrememnt ptr value by 10 location.

Answer:

int main(){

int x=3;

int *ptr=&x;

printf("%d\n", ptr);

char *p = (char*)ptr;

p+=10; //increments pointer by 10 bytes

ptr = (int *)p;

printf("%d\n",ptr);

}

Post Your Answer Here:      Public      Private

Rate This: +0 -1
Report     

Post Your Reply Here:     

Report Error

Report Error

Please Login First Click Here