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
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 |
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 |
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 |
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 |
Device an algorithm for weiler-atherton polygon clipping, where the clipping window can be any specified polygon
2.main { int x,j,k; j=k=6;x=2; x=j*k; printf("%d", x);
At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with these names could be kept in that shelf as in this example: bottom of shelf ---> [AAAJKRDFDEWAAYFYYKK]-----Top of shelf. All these packets are to be loaded on cars. The cars are lined in order, so that the packet could be loaded on them. The cars are also named [A, B, C, D, E,………….]. Each Car will load the packet with the same alphabet. So, for example, car ‘A’ will load all the packets with name ‘A’. Each particular car will come at the loading point only once. The cars will come at the loading point in alphabetical order. So, car ‘B’ will come and take all the packets with name ‘B’ from the shelf, then car ‘C’ will come. No matter how deep in the shelf any packet ‘B’ is, all of the ‘B’ packets will be displaced before the ‘C’ car arrives. For that purpose, some additional shelves are provided. The packets which are after the packet B, are kept in those shelves. Any one of these shelves contains only packets, having the same name. For example, if any particular shelf is used and if a packet with name X is in it, then only the packets having names X will be kept in it. That shelf will look like [XXXXXXX]. If any shelf is used once, then it could be used again only if it is vacant. Packets from the initial shelf could be unloaded from top only. Write a program that finds the minimum total number of shelves, including the initial one required for this loading process.
How to check whether string is a palindrome, WITHOUT USING STRING FUNCTIONS?
2 Answers Aricent, Manipal University,
Is an array parameter is always "by reference" ?
how to make program without <> in libray.
what is a static function
Can you apply link and association interchangeably?
wats SIZE_T meant for?
Why does this code crash?
What is data structure in c programming?
What are global variables and how do you declare them?