given the piece of code
int a[50];
int *pa;
pa=a;
to access the 6th element of the array which of the
following is incorrect?
a.*(a+5)
b.a[5]
c.pa[5]
d.*(*pa + 5)

Answers were Sorted based on User's Feedback



given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the a..

Answer / karthik

void main()
{
int a[50]={1,2,3,4,1,55};
int *pa;
pa=a
printf("%d",*(pa+5));
}

we will the sixth element

its not pointer to the pointer ie *(*pa+5);

Is This Answer Correct ?    36 Yes 3 No

given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the a..

Answer / fazlur rahaman naik

d is the right answer.

Is This Answer Correct ?    19 Yes 2 No

given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the a..

Answer / jaya prakash

Answer is D.
It is not a pointer to pointer.So we cannot use two stars.

Is This Answer Correct ?    6 Yes 1 No

given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the a..

Answer / yatish m yadav

The wrong answer is
d> *(*pa+5)
here value pointed to by pa is accessed and added 5 to it
then trying to print the value at that address, which gives
us an warning with some garbage value.

Is This Answer Correct ?    4 Yes 1 No

given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the a..

Answer / vignesh1988i

d) is the wrong choice...... because , first variable pa
refers to a address of the array... * of that pa will give
you the first value of the array.. ie a[0] , then that value
will be getting added with 5 and the * which is outside wont
have any value towards this manuplation...... so this will
show an error...... illegal use of pointers.....


thank u

Is This Answer Correct ?    2 Yes 0 No

given the piece of code int a[50]; int *pa; pa=a; to access the 6th element of the a..

Answer / shivangi

c is the wrong answer

Is This Answer Correct ?    0 Yes 5 No

Post New Answer

More C Interview Questions

without using arithmatic operator convert an intger variable x into x+1

3 Answers  


What are pointers in C? Give an example where to illustrate their significance.

0 Answers   Wipro,


What is scope and lifetime of a variable in c?

0 Answers  


What is the diffences between Windows XP and Windows Visa

1 Answers   Aricent, FHF,


Is array a primitive data type in c?

0 Answers  






Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)

0 Answers  


plz answer....A program that takes 3 variables e.g a,b,c in as seperate parameters and rotates the values stored so that value goes a to b, b to c and c to a .

3 Answers  


What does typeof return in c?

0 Answers  


Explain the use of #pragma exit?

0 Answers  


4-Take two sets of 5 numbers from user in two arrays. Sort array 1 in ascending and array 2 in descending order. Perform sorting by passing array to a function mySort(array, sortingOrder). Then multiply both the arrays returned from function, using metric multiplication technique in main. Print result in metric format.

0 Answers   TCS,


Is null a keyword in c?

0 Answers  


What is the Purpose of 'extern' keyword in a function declaration?

0 Answers  


Categories