KEMBAR78
CT - Input and Output Statements in C.pptx
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
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.
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);
getchar()
 It reads a single character from the keyboard.
•
fgets()
fgets() reads the given number of
characters of a line from the input and
stores it into the specified string.
It can read multiple words at a time
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);
putchar()
 It prints a single character to the screen.
•
fputs()
The fputs() function is 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

CT - Input and Output Statements in C.pptx

  • 1.
    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);
  • 5.
    getchar()  It readsa single character from the keyboard.
  • 6.
    • 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);
  • 9.
    putchar()  It printsa single character to the screen.
  • 10.
    • 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