int main() { int i=10; void pascal f(int,int,int); f(i++, i++, i++); printf("…
int main()
{
int i=10;
void pascal f(int,int,int);
f(i++, i++, i++);
printf(" %d",i);
return 0;
}
void pascal f(integer :i,integer:j,integer :k)
{
write(i,j,k);
}Answer: C. Compiler Error — Concept: The `pascal` keyword is a non-standard C extension (supported by older Borland/Turbo C compilers) that only changes a function's argument-passing…
- A.
11 11 11
- B.
11 12 13
- C.
Compiler Error
- D.
10 11 12
Attempted by 31 students.
Show answer & explanation
Correct answer: C
Concept: The `pascal` keyword is a non-standard C extension (supported by older Borland/Turbo C compilers) that only changes a function's argument-passing convention — it forces left-to-right evaluation of the arguments, in contrast to the classic `cdecl` convention (the C standard itself leaves the order of function-argument evaluation unspecified, but many legacy compilers such as Turbo C evaluated right to left under `cdecl`). It does NOT allow Pascal-language syntax or Pascal library routines inside the C function body: every type name and every function called must still be valid, declared C.
Application:
The prototype `void pascal f(int,int,int);` is syntactically valid C — `pascal` is applied to an otherwise normal `int` parameter list.
The definition below it, however, is written as `void pascal f(integer :i,integer:j,integer :k)`. `integer` is not a C type (C's is `int`), so this is a hard, unconditional syntax/unknown-type error on any C compiler.
Inside the body, `write(i,j,k);` calls `write` — a name that is never declared, prototyped, or included (unlike `printf`, which comes from `stdio.h`) anywhere in this program. On a standards-conforming compiler this is also a compile error (use of an undeclared identifier as a function); even a very old K&R-style compiler that only warns on an undeclared call would still fail to compile on the `integer` type-name error above, which by itself is sufficient.
So the program is caught at compile time, before linking or execution — the call `f(i++, i++, i++)` and its argument-evaluation order never actually run.
Cross-check:
Replacing the definition with valid C — `void pascal f(int i, int j, int k) { printf("%d %d %d", i, j, k); }` — WOULD compile. Because `pascal` forces left-to-right evaluation, that corrected version would print `10 11 12` from inside `f` (i stepping 10→11→12 across the three arguments) and then `13` from the `printf` in `main` once i has been incremented a third time. This confirms the `pascal` keyword itself is not the problem here — the invalid `integer` type name (and the undeclared `write` call) are.
Result: the program fails to compile — Compiler Error.