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 4 of 6.

Manoj said:   1 decade ago
Change the position of a[i] with respect to the position of the second element of the array.

Saif said:   5 years ago
The function isn't declared and defined after the main shouldn't be Wrong? Please explain.

Thomsika said:   1 decade ago
Can anyone explain me the concept clearly. I could not understand. What is the value of b?

XYZ said:   1 decade ago
*(a+i)=a[i]. that should give the address of a[i] right? why is it giving the value?

Sun said:   1 decade ago
When we Run this program will get the answer B.

How is it ? any one can explain. ?

Abi said:   1 decade ago
I can't understand how the answer is option b? someone explains if you knows.

Gowri said:   1 decade ago
I can t understand this prob how it work.

Some one explain for me.

Manikanth said:   1 decade ago
Void type cannot return anything to the main function.

Ashishprabhakar said:   1 decade ago
Thanks dev except you all gave wrong information.

Rahul W said:   9 years ago
Nice and well explanation, Thank you all guys!


Post your comments here:

Your comments will be displayed after verification.