Function Call and Return in C – How add(3, 4) Becomes 7

add(3, 4) — the simplest function call in C. Too simple to get wrong? The wrong options in this question from our C Programming Quiz App each encode a real beginner misconception about what a function call is: how arguments travel in, and how the result travels back.

The Quiz Question

int add(int a, int b) { return a + b; }
printf("%d", add(3, 4));

What is printed by this code?

  1. 7
  2. 34
  3. 0
  4. Compile error

The Correct Answer: 7

The call add(3, 4) copies 3 into parameter a and 4 into parameter b, evaluates a + b = 7, and return hands that value back to the caller — where it becomes the value of the expression add(3, 4) itself. printf receives a plain int 7. Verified on gcc 13.3 and Apple clang 21, clean under -ansi -Wall -Wextra:

$ gcc -ansi -Wall -Wextra call.c && ./a.out
7

Why Each Wrong Answer Is Wrong

Why not 34?

34 is the “concatenation” reading — as if the two arguments were glued together like strings. In C, + on two ints is always arithmetic addition. (You could get the text 34 from printf("%d%d", 3, 4) — two separate conversions — but that’s a formatting effect, not addition.) Languages where + concatenates have trained this reflex; C never does it, and C has no operator overloading to change that.

Why not 0?

0 would be the result if the function’s return value vanished — a mental model where return just ends the function. The returned value really is the call expression’s value; nothing needs to be “stored” first. printf("%d", add(3, 4)) is exactly as direct as printf("%d", 7).

Why not a compile error?

The function is defined before use with a full prototype-style signature, the argument types match, and the return type matches %d. Both compilers are silent with all warnings on. (The historical gotcha — calling an undeclared function — was legal-with-a-warning under C90’s implicit-int rule and became a hard constraint violation in C99; modern compilers reject it. Declared and defined as here, there’s nothing to object to.)

What a Call Actually Does, Step by Step

  1. Evaluate the arguments — 3 and 4 here (order unspecified when they’re expressions; a story of its own — see argument evaluation order).
  2. Copy each argument into the corresponding parameter. Parameters are fresh local variables of the function — this is pass-by-value, the subject of the next question in this cluster.
  3. Run the body until return expr; — the expression is converted to the declared return type if needed.
  4. The call expression assumes the returned value, and the caller continues. On mainstream platforms the value physically travels back in a register, but the language-level contract is simply: the call has that value.

One practical habit worth building early: a caller is free to ignore a return value, and C won’t warn by default — which is how forgotten malloc checks and unexamined error codes are born. If a function returns something meaningful, use it.

Frequently Asked Questions

What does add(3, 4) evaluate to in C?

The int value 7. The call expression itself has the returned value, so it can sit anywhere an int can — inside printf, in arithmetic, as another function’s argument.

Do function arguments in C get added as strings?

No. + on integers is always arithmetic, and C has no operator overloading. The “34” answer would only come from printing 3 and 4 side by side as separate conversions.

Does a C function need to be declared before it is called?

Since C99, yes — calling an undeclared function is a constraint violation (C90 tolerated it via implicit int). Define the function first, or provide a prototype above the call, as this code does.

Related Reading

Recommended Books

This question is #51 in the C Programming Quiz App — 155 questions with explanations covering functions, pointers, memory, and more.
Download on Google Play →

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>