Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 9
The getch() function basically stands for 'get character'. As one would understand from the title, getch() gets a character from the user. The getch() function is usually used to hold the output screen until the user presses on the keyboard, i.e. the case of pressing any key to continue. In order to use getch(), the header file <conio.h> has to be included. e.g. cout << "Press any key to continue." << endl; getch(); The return keyword on the other hand is used in the function definition to return a value of the function type. The main() function which is int will return a value of type int, usually 0, to signal the system that the program has run successfully. In user-defined function, return can be used by all types of functions except void functions to return a specific value to main(). Void functions do not have return type. e.g. int somefunc(int x) { int num = x + 7; return num; // function returns num value }
21st Dec 2016, 12:19 PM
Hatsy Rei
Hatsy Rei - avatar