Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Managing Input and Output Operations

Prof. Kuntal Patel


Ahmedabad University
Topics to be covered

Managing Input and Output Operations

 Input and output facilities under <stdio.h>


 Standard input and output operations
 Formatted input/output
 Format specifiers
Standard input and output operations

 Input and output facilities are provided by the standard library


<stdio.h> and not by the language itself.

Standard input and output

• int putchar(int)
• putchar(c) puts the character c on the standard output.
• it returns the character printed or EOF on error.

• int getchar()
• returns the next character from standard input.

• Data can be taken from a File

Demonstration and Discussion


printf() – format specification

%[flags][width ][. precision][modifier]<type>

Format Output
printf ("%d", 101) 101
printf ("%5d",101) SS101 [s is space]
printf ("%s",“INDIA") INDIA
printf ("%7s","hello") SSINDIA
Demonstrations
Output Operations using:
• putchar
• putc
• puts
• printf

Input Operations using:


• getchar
• getc
• gets
• scanf
Topics covered

Key topics covered during session:

 Input and output facilities under <stdio.h>


 Standard input and output operations
 Formatted input/output
 Format specifiers
 Demonstration related to important I/O functions

You might also like