C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 22)
22.
What will be the output of the program ?
#include<stdio.h>

int main()
{
    int i, a[] = {2, 4, 6, 8, 10};
    change(a, 5);
    for(i=0; i<=4; i++)
        printf("%d, ", a[i]);
    return 0;
}
void change(int *b, int n)
{
    int i;
    for(i=0; i<n; i++)
        *(b+1) = *(b+i)+5;
}
7, 9, 11, 13, 15
2, 15, 6, 8, 10
2 4 6 8 10
3, 1, -1, -3, -5
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
52 comments Page 5 of 6.

Nakul said:   8 years ago
What is the prototype of change function?

Ramya said:   1 decade ago
Can you explain the answer in detail?

Nirlep said:   1 decade ago
But in *(a+1) it is not incremented.

Mrinal said:   8 years ago
How the first element printed is 2?

Sujitha S said:   9 years ago
Which is the correct answer A or B?

Suraj said:   8 years ago
The answer is B @Devendar.

Gowthami said:   1 decade ago
Thanku surendra and Atul.

PRATHYUSHA said:   8 years ago
Thank you @Pankaj Singh.

Arun tomar said:   1 decade ago
Nice explanation atul.

Vaibhav said:   6 years ago
Why? Please explain.


Post your comments here:

Your comments will be displayed after verification.