Download presentation
Presentation is loading. Please wait.
Published byAnthony Chapman Modified over 9 years ago
1
Basic Input - Output
2
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 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
3
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. 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.
4
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
5
Format Specifier % ccharacter %%%%sstring %%%%dinteger %%%%ffloat %%%%eexponential %%%%xhexadecimal %%%%ooctal %%%%ldlong integer %%%%lflong float / double precision
6
Declaration of Variables A variable is a named data storage location in your computer’s 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.
7
Variable Type Keyword Bytes Required Range Characterchar1 -128 to 127 Integerint2 -32768 to 32767 Long integer iong int 4 -2147483648 to 2147483647 Floatfloat4 1.2E-38 to 3.4E38 Double precision double8 2.2E-308 to 1.8E308
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.