#include
int g(int n) { return (n+10); }
int f(int n) { return g(n*2); }
int main() {
int sum, n;
sum=0;
for (n=1; n<3; n++)
sum += g(f(n));
printf("%d", sum);
return 0;
}
Solution :
The correct answer is 46.
To find the output of the given C program, we can trace its execution step-by-step.
First, let's analyze the functions defined in the program:
1. Function takes an integer input and returns .
2. Function takes an integer input and returns . Substituting the definition of , we have:
Inside the main function, the variable sum is initialized to 0. A for loop runs for n = 1 and n = 2 (as long as n < 3).
Iteration 1: n = 1
We calculate the value of :
Now, we compute :
Updating the sum: sum = 0 + 22 = 22.
Iteration 2: n = 2
We calculate the value of :
Now, we compute :
Updating the sum: sum = 22 + 24 = 46.
After the second iteration, the loop terminates. The final value printed is 46.
Completely free for students. Educators & coaching institutes get 2 months free Pro trial to create tests.
Access unlimited practice questions, detailed step-by-step solutions, and exam study materials — completely free for students.
Create and conduct professional online assessments with AI question generation, tab proctoring, and comprehensive batch management.
A comprehensive CUET UG Mathematics Question Paper with Solutions – 2 June 2023 (Shift 3) designed to help students practice and understand the actual CUET exam pattern. This paper covers important topics from Algebra, Calculus, Coordinate Geometry, Probability, Statistics, Matrices, Determinants, and Vectors, featuring a balanced mix of conceptual, numerical, and application-based questions. Detailed solutions are provided to strengthen problem-solving skills, improve conceptual clarity, and enhance calculation accuracy. Based on the CUET syllabus and previous year exam trends, this paper is ideal for practice, revision, self-assessment, time management, previous year analysis, and final preparation for upcoming CUET UG Mathematics examinations.
A comprehensive CUET Accountancy Question Paper – 20 June 2023 (Shift 2) designed to help students practice and analyze previous year exam patterns for effective CUET preparation. This paper covers important topics including Accounting for Partnership Firms, Company Accounts, Financial Statements Analysis, Cash Flow Statements, Accounting Ratios, and Fundamental Accounting Principles. It features a balanced mix of conceptual, numerical, and application-based questions to strengthen accounting concepts, improve calculation accuracy, and enhance problem-solving skills. Based on the CUET exam structure and syllabus, this paper is ideal for practice, revision, self-assessment, time management, previous year analysis, and final preparation for upcoming CUET Accountancy examinations.
Copyright © 2026 Combe Labs Private Limited. All Rights Reserved.