• retagged by
1,574 views
1 1 vote

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

4 Answers

1 1 vote
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 1 vote
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 0 votes
I am getting 12,4,4 some changes need to be done in options/in question......you please check ones both
Position:
Show:

Related questions

2 2 votes
1 1 answer
2.1k
2.1k views
dd asked Apr 29, 2017
2,096 views
Assume sizeof int as 4#include <stdio.h unsigned int L = (sizeof(unsigned int)) << 3; int foo(unsigned int m,unsigned int start,unsigned int length) { length = length > 1...
0 0 votes
1 1 answer
1.2k
1.2k views
sushmita asked Mar 27, 2017
1,176 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 0 votes
1 answers 1 answer
1.5k
1.5k views
Desert_Warrior asked May 16, 2016
1,521 views
main() { int c=- -2; printf("c=%d",c); }
0 0 votes
2 answers 2 answers
2.2k
2.2k views
Desert_Warrior asked May 16, 2016
2,200 views
void main() { unsigned giveit=-1; int gotit; printf("%u ",++giveit); printf("%u \n",gotit= giveit); }