Correct Answer - Option 3 : 1 - d, 2 - a, 3 - b, 4 - c
The following C commands are used for the following:
- It reads also a single character from the keyboard. But it does not use any buffer, so the entered character is immediately returned without waiting for the enter key.
- getch() is a nonstandard function and is present in conio.h header file which is mostly used by MS-DOS compilers like Turbo C. It is not part of the C standard library or ISO C.
- Syntax: int getch();
It is not necessary that every time you should use return 0 to return the program's execution status from the main() function. But returned value indicates the program's success or failure to the operating system and there is only one value that is 0 which can indicate success and other non-zero values can indicate failure of execution due to many reasons.
For example - if the program's execution fails due to lake of memory we can return -1, if it fails due to file opening we can return -2, if it fails due to any invalid input value we can return -3, and so on. If the program's execution is a success we should return 0.
This indicates the end of the main function. When we write the last line of the code in main, we need to close the main() function by terminating the program with }.
1. The main() function is like other functions. It also takes arguments and returns some value. One point we have to keep in mind that the program starts executing from this main() function. So the operating system calls this function. When some value is returned from the main(), it is returned to the operating system.
2. The int main() indicates that the main() can return integer type data.
Hence option (3) is the correct answer.