retagged by
1,062 views
1 votes
1 votes

Q. Consider the C program shown below

#include <stdio.h>

#define print (a) printf (“%d”, a)

int a;

void A (int p)

{

            p+ = a;

            print (p);

}

void B(int *q)

{

            int p = *q + 3;

            A (a);

            *q = a – 2;

            print  (a);

            }

Main (void)

{

            a = 6;

            B(&a);

            print(a);

}

The output of this program is

(a) 15, 7, 6                                                                   (b) 15, 7, 7

(c) 13, 7, 6                                                                   (d) 13, 7, 7

retagged by

4 Answers

1 votes
1 votes
output of this code is 12 4 4  i think something correction in options.

first  call the function B

without changing the value of a we call to A so print -->12

return to function B

change the value a=6-2=4;

print value of a--->4

return in main function

print value of a-->4
1 votes
1 votes
OPTION A)IS CORRECT IF WE MODIFY THE CODE AS

#include <stdio.h>

#define print (a) printf (“%d”, a)

int a;

void A (int p)

{

            p+ = a;

            print (p);

}

void B(int *q)

{

            int p = *q + 3;

            A (p);

            *q = p – 2;

            print  (*q);

            }

Main (void)

{

            a = 6;

            B(&a);

            print(a);

}

The output of this program is
0 votes
0 votes
I am getting 12,4,4 some changes need to be done in options/in question......you please check ones both

Related questions

2 votes
2 votes
1 answer
1
0 votes
0 votes
1 answer
2
sushmita asked Mar 27, 2017
512 views
Find the out put of the following C program. main() { char *ptr = "techtud"; char p= (*ptr)++; printf("%s\n",ptr); }the output of the program came as$?$
0 votes
0 votes
1 answer
3
Desert_Warrior asked May 16, 2016
978 views
main() { int c=- -2; printf("c=%d",c); }
0 votes
0 votes
2 answers
4
Desert_Warrior asked May 16, 2016
1,259 views
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit= giveit); }