Use app×
Join Bloom Tuition
One on One Online Tuition
JEE MAIN 2025 Foundation Course
NEET 2025 Foundation Course
CLASS 12 FOUNDATION COURSE
CLASS 10 FOUNDATION COURSE
CLASS 9 FOUNDATION COURSE
CLASS 8 FOUNDATION COURSE
0 votes
106 views
in Information Technology by (85.4k points)
closed by

The value printed by the following program is _______.

void f (int* p, int m) {

m = m + 5;

*p = *p + m;

return;

}

void main () {

        int i=5, j=10;

        f (&i, j);

        printf (‘’%d’’, i+j);

}

1 Answer

0 votes
by (88.5k points)
selected by
 
Best answer

Code Explanation:

In this code, address of i is passed to the function and value of j is passed.

Given i =5, j= 10

void f (int* p, int m) { //here p points to address of i and m contains 5

            m = m + 5; // m becomes 15

            *p = *p + m; // p becomes 20

            return;

}

When call returns back to the main function, i value changes to 20 but j will remain same.

So, printf (‘’%d’’, i + j); // 20 + 10 = 30 is printed

Welcome to Sarthaks eConnect: A unique platform where students can interact with teachers/experts/students to get solutions to their queries. Students (upto class 10+2) preparing for All Government Exams, CBSE Board Exam, ICSE Board Exam, State Board Exam, JEE (Mains+Advance) and NEET can ask questions from any subject and get quick answers by subject teachers/ experts/mentors/students.

Categories

...