Arizona State University (ASU) CSE240 Introduction to Programming Languages Midterm Practice Exam

Question: 1 / 400

True or False: C allows both void and int as the return type for main.

True

In C, the `main` function serves as the entry point for program execution and it is designed to return an integer value. According to the C standard, the return type of `main` should typically be `int`, indicating that the program has executed successfully or has encountered some error (when returning a non-zero value).

While it is technically permissible to define `main` with a return type of `void` in some non-standard compilers, this is not compliant with the C standard. Only defining `main` as returning `int` is considered standard practice and is widely supported across different compilers.

Therefore, the correct response recognizes only `int` as an official return type for `main` under the standard C definition. Thus, the claim that both void and int are allowed is misleading since adhering to the standard ensures consistent and predictable behavior across different environments.

In summary, the accurate perspective is that `main` should return `int` according to the C standard specification, while `void` can lead to undefined behavior or be unsupported in practice.

Get further explanation with Examzify DeepDiveBeta

False

Only int is allowed

Only void is allowed

Next Question

Report this question

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy