Question:
Definition of getch() and printf() in C?
Taha
2013-11-16 01:41:40 UTC
Please can some one give simple definitions for the following terms in C language.

1.Header files
2.printf()
3.getch()
4.clrscr()
5.Basic input/output method
6. variable declaration
7. variable initialization

Thanks in advance ....easy 5 stars :)
Four answers:
MeMeMe
2013-11-16 02:02:51 UTC
1. Header files are files that are meant to be included by a source file. The #include statement has the compiler parse the header file as if you pasted its content into your source file. Header files usually contain only macros, type definitions and function prototype, although this is more of a convention than a strictly enforced rule.

2. printf() is a function that takes a format string (something like "Hello, %s.\n") and a set of arguments, creates a new string based on the format string and the arguments passed and sends this string to the standard input output stream.

3. getch() is a function from the non-standard conio library that reads an input character from the active console (i.e. reads a function from the keyboard)

4. clrscr() is a function from conio that clears the content of the screen to the current textmode background color.

5. ???

6. A variable declaration tells the compiler the name and the type of a variable. In C it looks something like this:



int x;



7. A variable initialization assigns an initial value to a variable:



int [x = 17];



The brackets here are not actually part of a valid C statement, I just added them to show you the initialization.
Agyey
2013-11-16 10:08:23 UTC
1. They are preprocessed files that are used by the complier and include some of the predefined functions.



2. printf() is used to print a message onto the screen.



3. getch() is used to accept a character from the user, its generally used in after a printf statement to acknowledge that the user has read the message, its like the screen displays hi and then the user hits enter so that the code proceeds on.



4. clrscr() is used to clear the screen of any previous outputs.



5. Basic input method is keyboard and basic output method is user's screen



6. variable declaration is used to declare a variable to be used later in the program.



7. variable initialisation is used to give the variable an initial value.
James Bond
2013-11-16 09:59:36 UTC
1.Header files: contains ready made functions prototypes or declarations or signature. Declaration of function indicates how many arguments and what type of arguments we have to send to the function and what it returns.



2.printf(): it is a function to display something on the monitor

3.getch(): it is also a function which reads a character from key board

4.clrscr(): it is a functoon which clears the screen

5.Basic input/output method: scanf for taking input from keyboard and printf is for displaying on monitor

6. variable declaration: int a, b,c;

The above is a variable declaration statement which allocates memory for three integer type variables a,b,c. Here, int indicates type of variable and while a,b,c are names of variables. We have other type of variables such as float, char, long, double etc.

7. variable initialization
2013-11-16 10:04:37 UTC
1) A header file is a file with extension .h which contains C function declarations and macro definitions and to be shared between several source files. 2) printf functions (which stands for "print formatted") are a class of functions typically associated with curly bracket... 3) getch() returns the character you typed without displaying it on the screen. 4) clrscr() clear previous compiled program from screan when you are going to compiled another one


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...