GATE Exam  >  GATE Questions  >  What are the outputs of the following program... Start Learning for Free
What are the outputs of the following program?
main()
{
int u =1;
int v = 3;
printf(“u = %d”, v =%d”, u, v);
funct1(u, v);
printf(“u = %d”, v = %d”, u, v);
funct2(&u, &v);
printf(“u = %d”, v = %d”, u, v);
}
funct1( int u, int v)
{
u = u + v;
v = u – v;
u = u – v;
}
funct2( int *pu, int *pv)
{ *pu = *pu + *pv;
*pv = *pu - *pv;
*pu = *pu - *pv;
}
  • a)
    u = 1 v = 3 u =1 v = 3 u =3 v = 1
  • b)
    u = 1 v = 3 u =3 v = 1 u =1 v = 3
  • c)
    u = 1 v = 3 u =3 v = 1 u =3 v = 1
  • d)
    u = 1 v = 3 u =1 v = 3 u =1 v = 3
Correct answer is option 'A'. Can you explain this answer?
Verified Answer
What are the outputs of the following program?main(){int u =1;int v = ...
First printf prints u = 1 v = 3
Again funct1 (u, v) in called
→ funct1(1, 3)
→ u = u + v = 1 + 3 = 4
v = u – v = 4 -3 = 1
u = u – v = 4 – 1 = 3
Again printf will print u = 1 v = 3 because values of u and v actually have not changed
When funct2 (&u, &v); is called
And it is called reference hence the values of u and v are actually interchanged
→ When third printf (c) is executed, the values of u and v are actually interchanged
View all questions of this test
Explore Courses for GATE exam
What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer?
Question Description
What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer? for GATE 2024 is part of GATE preparation. The Question and answers have been prepared according to the GATE exam syllabus. Information about What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer? covers all topics & solutions for GATE 2024 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer?.
Solutions for What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer? in English & in Hindi are available as part of our courses for GATE. Download more important topics, notes, lectures and mock test series for GATE Exam by signing up for free.
Here you can find the meaning of What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer?, a detailed solution for What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer? has been provided alongside types of What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice What are the outputs of the following program?main(){int u =1;int v = 3;printf(“u = %d”, v =%d”, u, v);funct1(u, v);printf(“u = %d”, v = %d”, u, v);funct2(&u, &v);printf(“u = %d”, v = %d”, u, v);}funct1( int u, int v){u = u + v;v = u – v;u = u – v;}funct2( int *pu, int *pv){ *pu = *pu + *pv;*pv = *pu - *pv;*pu = *pu - *pv;}a)u = 1 v = 3 u =1 v = 3 u =3 v = 1b)u = 1 v = 3 u =3 v = 1 u =1 v = 3c)u = 1 v = 3 u =3 v = 1 u =3 v = 1d)u = 1 v = 3 u =1 v = 3 u =1 v = 3Correct answer is option 'A'. Can you explain this answer? tests, examples and also practice GATE tests.
Explore Courses for GATE exam
Signup for Free!
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev