---
title: "Significance of main() function"
subject: "Computer Programming"
chapter: 6
key: "semester_1/computer_programming:significance-of-main"
source: https://www.bctengineer.com/q/semester_1/computer_programming/significance-of-main
site: BCT Engineering
---

# Significance of main() function

Computer Programming · Chapter 6: User-Defined Functions

- Asked in: 2069 Asar, 2 marks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/significance-of-main
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-6

## Question

Write down significance of main( ) function in C.

## Short answer

The main() function is the entry point where program execution starts and ends; it controls overall flow and must appear exactly once. It returns an integer to the OS (0 indicates success) and can accept command-line arguments via parameters.

## Answer

`main()` is the function where every C program begins execution.

- The operating system calls `main()` at the start; the program ends when `main()` returns.
- Every program must have exactly one `main()` function.
- It contains (or calls) all the statements and functions of the program, so it controls the program flow.
- It returns an integer to the operating system: `return 0;` means successful execution, a non-zero value means an error.
- It can receive command-line arguments through `int main(int argc, char *argv[])`.

```c
#include <stdio.h>
int main(void)
{
    printf("Program starts here\n");
    return 0;   /* 0 tells the operating system the program ended normally */
}
```
Output:
```text
Program starts here
```

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Execution begins where?
   A. First function
   B. Last
   C. main()
   D. Prototype
   Answer: C. Entry. (Key point: Start)

2. How many main?
   A. Any
   B. Two
   C. None
   D. Exactly one
   Answer: D. One. (Key point: Count)

3. return 0 means?
   A. Success to OS
   B. Error
   C. Nothing
   D. Stop loop
   Answer: A. Normal. (Key point: Return 0)

## Related in Computer Programming

- [Significance of arrays; multiply 3×3 matrices](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aarray-significance-multiply-matrices) — Computer Programming, chapter 7
- [Sort array using a function](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aarray-sort-function) — Computer Programming, chapter 7
- [Compare two strings with function](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astring-compare-function) — Computer Programming, chapter 7

## Related in other subjects

- [Inline function: significance and limits](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Ainline-function) — Object Oriented Programming, chapter 3, asked 3×
- [Wave function significance; time independent equation](https://www.bctengineer.com/question.md?key=semester_1%2Fengineering_physics%3Aschrodinger-time-independent-significance) — Engineering Physics, chapter 10, asked 2×
- [Unit impulse function and its significance](https://www.bctengineer.com/question.md?key=semester_5%2Fdata_communication%3Aunit-impulse-significance) — Data Communication, chapter 2
- [Impulse response and transfer function significance](https://www.bctengineer.com/question.md?key=semester_6%2Fcommunication_systems%3Aimpulse-response-transfer-significance) — Communication Systems, chapter 1
