what is full defination of getch , getchar , getche ,printf ,scanf,getchar, in c

  1. vinay sharma  ji profile image54
    vinay sharma jiposted 7 years ago

    what is full defination of getch , getchar , getche ,printf ,scanf,getchar, in c language

  2. johnsams profile image70
    johnsamsposted 7 years ago

    getch() returns the character you typed without displaying it on the screen.

    getchar() works similarly and displays the character that you typed on the screen after "enter" is given.

    getche() returns the character you typed by displaying(echoing) it on the screen.

    The printf function prints output to stdout, according to format and other arguments passed to printf. The string format consists of two types of items: characters that will be printed to the screen, and format commands that define how the other arguments to printf are displayed.

    In simple words printf function prints formatted output to a file.

    scanf() function reads input from stdin, according to the given format, and stores the data in the other arguments. It works a lot like printf().

  3. parmindermaan profile image49
    parmindermaanposted 7 years ago

    1) getchar () function reads a single character from standard input. It takes no parameters and its returned value is the input character. In general, a reference to the getchar function is written as character
    variable = getchar();
    For example char c;
    c= getchar () ;
    The second line causes a single character to be entered from the standard input device and then assigned to c.If an end-of-file condition is encountered when reading a character with the getchar function, the value of the symbolic constant EOF will automatically be returned. This function can also be used to read multicharacter strings, by reading one character at a time within a multipass loop.

    2) The getch() Function
    The getch() function obtains the next character from the stream stdin. It provides unbuffered character input without echo. The getch() function isn”t part of the ANSI standard. This means that it might not be available on every system. Additionally, it might require that different header files be included. Generally, the prototype for getch() is in the header file CONIO.H, as follows:
    int getch(void);

    Because it is unbuffered, getch() returns each character as soon as the key is pressed, without waiting for the user to press Enter. Because getch() doesn’t echo its input, the characters aren”t displayed on-screen. The following function uses getch(), which is not ANSI-compliant. There is no guarantee that all compilers support non-ANSI functions.

    3)scanf():-Input data can be entered into the computer from a standard input device by means of C library function scanf. This function can be used to enter any combination of numerical values, characters single character and strings. The function returns the number of data items that have been entered successfully.
    In general terms, the scanf function is written as
    scanf (string, parameter 1, parameter 2…, parameter n);

    Where string= string containing certain required formatting information, and Parameter 1, parameter 2.. = parameters that represent the individual input data item. The control string or string comprises individual groups of characters, with one character group for each input data item. Each character
    group must start with percent sign (%). In the string, multiple character groups can be contiguous, or separated by white space characters. The conversion character that is used with % sign are many in number and all have different meaning corresponding to type of data item that is to be input from keyboard.

    4)printf():-A printf() format string specifies how the output is formatted. Here are the three possible components of a format string:
    •    Literal text is displayed exactly as entered in the format string. In the preceding example, the characters starting with the T (in The) and up to, but not including, the % comprise a literal string.
    •    An escape sequence provides special formatting control. An escape sequence consists of a backslash (\) followed by a single character. In the preceding example, \n is an escape sequence. It is called the new line character, and it means "move to the start of the next line." Escape sequences are also used to print certain characters
    •    A conversion specifier consists of the percent sign (%) followed by a single character. In the example, the conversion specifier is %d. A conversion specifier tells printf() how to interpret the variable(s) being printed. The %d tells printf() to interpret the variable x as a signed decimal integer