Basic Input - Output
Output functions printf() – is a library function that displays information on-screen. The statement can display a simple text message or a message and the value of one or more program variables printf() – is a library function that displays information on-screen. The statement can display a simple text message or a message and the value of one or more program variables gotoxy() – positions the cursor on a specific location on the screen gotoxy() – positions the cursor on a specific location on the screen clrscr() – clears the screen and place the cursor at the upper left hand portion of the screen clrscr() – clears the screen and place the cursor at the upper left hand portion of the screen
Input functions scanf() – reads data from the keyboard according to a specified format and assigns the input data to one or more program variables. For numeric variables, the address can be passed by the address of operator, the ampersand (&) that is placed at the beginning of the variable name. scanf() – reads data from the keyboard according to a specified format and assigns the input data to one or more program variables. For numeric variables, the address can be passed by the address of operator, the ampersand (&) that is placed at the beginning of the variable name. getch() / getche() – gets a character from the keyboard. It waits until a key is pressed and then returns the inputted character to the calling function. Unlike the scanf() function, getch/e() does not wait for the carriage return key to be pressed. getch() / getche() – gets a character from the keyboard. It waits until a key is pressed and then returns the inputted character to the calling function. Unlike the scanf() function, getch/e() does not wait for the carriage return key to be pressed. The difference between the getch() and getche() is that the latter echoes the typed character to the screen.
Escape Sequences \ \rcarriage return \nnewline \tmove to the next tab \abeep the speaker \bbackspace prints single quote \prints double quote \\prints backslash character \xddprints character whish is in hexadecimal form
Format Specifier % %ccharacter %sstring %dinteger %ffloat %eexponential %xhexadecimal %ooctal %ldlong integer %lflong float / double precision
Declaration of Variables A variable is a named data storage location in your computers memory. Variables in C can contain letters, digits and the underscore character ( _ ). It should be remembered that C language is case sensitive; two similar words in different cases generate two different variables. A variable declaration tells the compiler the name and type of a variable and optionally initializes the variable to a specific value. When a variable is declared, the compiler sets aside a storage space for the variable.
Variable Type Keyword Bytes Required Range Characterchar to 127 Integerint to Long integer iong int to Floatfloat4 1.2E-38 to 3.4E38 Double precision double8 2.2E-308 to 1.8E308