INPUT AND OUTPUT
STATEMENTS
Class: I B.Sc Cyber Security
Subject : Coding Techniques
Subject Code : U24EM101
Presented By Mr. S.Vignesh (AP/CS)
Department of Computer Science
2.
Introduction
Input →getting data from user
Output → displaying data to user
C uses <stdio.h>
(Standard Input/Output) header file
Provides functions like scanf(),
printf(), etc.
3.
Input Functions
scanf()→ formatted input
getchar() → read single character
fgets() → read string safely
scanf()
It is used to read user input from the
console.
It takes the format string and the
addresses of the variables where the
input will be stored.
SYNTAX
scanf("formatted_string", address_of_variables/values);
•
fgets()
fgets() reads thegiven number of
characters of a line from the input and
stores it into the specified string.
It can read multiple words at a time
7.
Output Functions
printf()→ formatted input
putchar() → read single character
puts() → read string safely
printf()
The printf() function is used to print
formatted output to the standard
output stdout (which is generally the
console screen).
It is one of the most commonly used
functions in C.
SYNTAX
printf("formatted_string", variables/values);
•
fputs()
The fputs() functionis used to output
strings to the files but we can also use
it to print strings to the console screen.
It just print text only and not
supported formatted output like printf