Presentation is loading. Please wait.

Presentation is loading. Please wait.

INTRODUCTION Every language has some features that provides interaction between the program and the user of the program. C language uses the reference.

Similar presentations


Presentation on theme: "INTRODUCTION Every language has some features that provides interaction between the program and the user of the program. C language uses the reference."— Presentation transcript:

1 INTRODUCTION Every language has some features that provides interaction between the program and the user of the program. C language uses the reference stdin for standard input devices and stdout for standard output devices. I/O FUNCTIONS

2 I/O FUNCTIONS

3 C language does not support or provide any input/output operations as a part of language,but the operations are provided as library functions . The input/output functions of C language are provided through the header file stdio.h Definations of various I/O functions is stored in the stdio.h header files. I/O FUNCTIONS

4 Various I/O functions printf() scanf() getchar() putchar() gets()
puts() I/O FUNCTIONS

5 printf Function The printf function writes output to stdout
Ex. printf("Average: %d \n“,Average); The first argument is a character string containing ordinary text, escape characters, and format specifiers. The escape character \n is used in the given line for newline. The order, number, and type of the format specifiers corresponds to the order, number, and type of the arguments in the printf call I/O FUNCTIONS

6 printf Examples No format specifiers, one escape character, no other arguments printf("Name Age Address Distance\n"); One format specifier, two arguments printf("Results is %d\n", theResult); Four format specifiers, five arguments printf("%c %d %f %s", aCharacter, anInteger, aFloat, aString); I/O FUNCTIONS

7 scanf Function The scanf function reads input from stdin
scanf(“number is %d", &Number); The first argument is a character string containing one or more conversion specifiers Each argument value must be represented by the address of the variable, NOT the variable itself, where the value should be stored To designate the address for a character, integer, structure, or floating point variable, precede the variable name by the & operator, which means "address of“. I/O FUNCTIONS

8 scanf Examples One format specifier. scanf("%d", &theResult);
Three format specifiers, four arguments scanf("%d%f%s", &anInteger, &aFloat, aString); Same as above, but in a different order scanf("%s %f %d", aString, &aFloat, &anInteger); I/O FUNCTIONS

9 Examples of Putchar Syntax of Putchar- putchar(charcter_variable)
For examples char c = ‘a’; Will display ‘a’ on the output screen. I/O FUNCTIONS

10 Examples of Getchar Syntax
Character_variable =getchar(); Where character_variable is a char type of variable.for exampe Char c; c= getchar(); Will store the ASCII value of the key pressed. I/O FUNCTIONS

11 Your Queries please.. I/O FUNCTIONS


Download ppt "INTRODUCTION Every language has some features that provides interaction between the program and the user of the program. C language uses the reference."

Similar presentations


Ads by Google