C Programming - Functions - Discussion

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

int main()
{
    void fun(char*);
    char a[100];
    a[0] = 'A'; a[1] = 'B';
    a[2] = 'C'; a[3] = 'D';
    fun(&a[0]);
    return 0;
}
void fun(char *a)
{
    a++;
    printf("%c", *a);
    a++;
    printf("%c", *a);
}
AB
BC
CD
No output
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
40 comments Page 4 of 4.

Swati said:   6 years ago
What will be the answer if pre-increament will be there?

SVP said:   10 years ago
What wiil be the answer when if we replace a++ to ++a ?

Syed Azar said:   1 decade ago
Is this the value of the a[0] changes with a++?

Niharika said:   9 years ago
Not getting this, Can anyone explain me?

Christopher said:   1 decade ago
I agree with Bagesh Kumar singh Point.

Pavan said:   1 decade ago
Can we declare a function within main?

Abhilasha said:   1 decade ago
What about the step fun(&a[0]);?

Supriya said:   8 years ago
Yes, I agree. Thank you all.

Manisha said:   9 years ago
Please explain clearly.

Jancy rani said:   9 years ago
a++ is post increment.


Post your comments here:

Your comments will be displayed after verification.