SlideShare une entreprise Scribd logo
1  sur  16
SCANF &PRINTF


Input Statement -> SCANF

     scanf() is used to give data to variables using keyboard
     scanf works very well when the viewer’s input has NO
     spaces



Output Statement ->PRINTF

     printf() is used to show the result of the program trough
     display device
GETS &PUTS
Input Statement -> GETS

    gets() function accepts an entire line of input from the
    standard input device (keyboard)




Output Statement ->PUTS

    It is complement of gets. Its display a string on the
    standard output device
REVISE LAB 3
Exercise 1
a.   #include<stdio.h>
     #include<conio.h>
     main()
     {
                                                  Enter subject name: Computer Programming
         char subject[20];
                                                  Your name is: Computer
         printf("Enter subject name:");
         scanf("%s", &subject);
         printf("Your name is: %s n",subject);
         getch();
               }




b.   #include<stdio.h>
     #include<conio.h>
     main()
     {
                                                  Enter subject name: Computer Programming
         char subject[20];
                                                  Your name is:
         printf("Enter a subject name:");
                                                  Computer Programming
         gets(subject);
         printf("Your name is: n");
         puts(subject);
         getch();
         }
Cannot read a multi-word string such as
                 computer programming
                  Its read only computer

        scanf terminates it input when it encounter a
            blank space such as space, tab, new
               line, form feed, carriage return.




      Overcomes the disadvantages of scanf functions

It can read any string length with any numbers of blank space
GETCHAR &PUTCHAR

       •   Define in the standard C header stdio.h


Input Statement -> GETCHAR

       •   getch is used to read a character with
           pressing the enter


Output Statement ->PUTCHAR

       •   Complement of the getchar function

       •   To display a single character on the
           standard output device
GETCH &PUTCH
      •   Accessed from <stdio.h> standard library


Input Statement -> GETCH
      •   getch is used to returns a single character typed in from the
          standard input device



Output Statement ->PUTCH

      •   As soon as key is pressed it stop accessing the keyboard.
      •   User don’t have to press the ENTER key.
REVISE LAB 3
Exercise 1
c.   #include<stdio.h>
     #include<conio.h>
     main()
     {
                                          Enter a character: Computer Programming
         char letter;
                                          Your Input is:
         printf("Enter a character:");
                                          C
         letter=getchar();
         printf("nYour input is: n");
         putchar(letter);
         getch();
               }




d.   #include<stdio.h>
     #include<conio.h>
     main()
     {
                                          Enter subject name:
         char letter;
                                          Your name is:
         printf("Enter a character:");
                                          C
         letter=getch();
         printf("nYour input is: n");
         putch(letter);
         getch();
               }
What is a STRING??
    a string is a character variable with more than
    one character.


    Strings can be
    abbreviations, words, phrases, sentences, or
    even paragraphs
Can be said as :

   Format specifier
   Format string
Format     Output Type                                  Output
Specifier                                               Example
  %d        Signed decimal integer                          76
  %i        Signed decimal integer                          76
  %o        Unsigned octal integer                         134
  %u        Unsigned decimal integer                        76
  %x        Unsigned hexadecimal (small letter)             9c
  %X        Unsigned hexadecimal (capital letter)           9C
  %f        Integer including decimal point              76.0000
  %e        Signed floating point (using e notation)   7.6000e+01
  %E        Signed floating point (using E notation)   7.6000E+01
  %g        The shorter between %f and %e                   76
  %G        The shorter between %f and %E                   76
  %c        Character                                       ‘7’
  %s        String                                         ‘76'
Why Use Format Specifier??


       Nature of c requires that I/0 operations
       be associated with specifier data types.
       This association is made with format and
       conversion specifiers.




       When use with the input statements,
       conversion specifiers tell what kind of
       variable is being read
Example

     scanf(“%lf”,& x);

     Tells C to interpret character
     type at the keyboard as real
     number of type double
Also said as sscape sequences

Its allow you to send nongraphic control characters to a display
device



    Basic Constant                     Effect
          a                         Beep sound
          b                         Backspace
           f                   Formfeed (for printing)
          n                          New line
           r                      Carriage return
           t                           Tab
          v                         Vertical tab
                                   Backslash
          ”                           “ sign
          o                        Octal decimal
          x                        Hexadecimal
          O                           NULL

Contenu connexe

Tendances (20)

Variables in C Programming
Variables in C ProgrammingVariables in C Programming
Variables in C Programming
 
Functions in C
Functions in CFunctions in C
Functions in C
 
String functions in C
String functions in CString functions in C
String functions in C
 
Input And Output
 Input And Output Input And Output
Input And Output
 
Presentation on Function in C Programming
Presentation on Function in C ProgrammingPresentation on Function in C Programming
Presentation on Function in C Programming
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
Dynamic memory allocation in c
Dynamic memory allocation in cDynamic memory allocation in c
Dynamic memory allocation in c
 
Character set of c
Character set of cCharacter set of c
Character set of c
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Presentation on C Switch Case Statements
Presentation on C Switch Case StatementsPresentation on C Switch Case Statements
Presentation on C Switch Case Statements
 
Strings in C
Strings in CStrings in C
Strings in C
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
C Programming: Control Structure
C Programming: Control StructureC Programming: Control Structure
C Programming: Control Structure
 
Function in C program
Function in C programFunction in C program
Function in C program
 
sorting and its types
sorting and its typessorting and its types
sorting and its types
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Conditional Statement in C Language
Conditional Statement in C LanguageConditional Statement in C Language
Conditional Statement in C Language
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 

En vedette

Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in cyazad dumasia
 
Input and output in c
Input and output in cInput and output in c
Input and output in cRachana Joshi
 
Input Output Management In C Programming
Input Output Management In C ProgrammingInput Output Management In C Programming
Input Output Management In C ProgrammingKamal Acharya
 
Input and Output Devices
Input and Output DevicesInput and Output Devices
Input and Output Devicescachs_computing
 
5 1. character processing
5 1. character processing5 1. character processing
5 1. character processing웅식 전
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functionsWay2itech
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...yazad dumasia
 
C presentation book
C presentation bookC presentation book
C presentation bookkrunal1210
 
Automotive Circuit Boards
Automotive Circuit BoardsAutomotive Circuit Boards
Automotive Circuit BoardsArt Wood
 
Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)Fendie Mimpi
 
Escape sequences
Escape sequencesEscape sequences
Escape sequencesWay2itech
 
RoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB FabricationRoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB FabricationArt Wood
 
Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...
Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...
Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...Art Wood
 
training_presentation
training_presentationtraining_presentation
training_presentationAniket Pawar
 
Epoxy flux a low cost high reliability approach for pop assembly-imaps 2011
Epoxy flux  a low cost high reliability approach for pop assembly-imaps 2011Epoxy flux  a low cost high reliability approach for pop assembly-imaps 2011
Epoxy flux a low cost high reliability approach for pop assembly-imaps 2011nclee715
 

En vedette (20)

Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
Managing input and output operation in c
Managing input and output operation in cManaging input and output operation in c
Managing input and output operation in c
 
Input and output in c
Input and output in cInput and output in c
Input and output in c
 
Input Output Management In C Programming
Input Output Management In C ProgrammingInput Output Management In C Programming
Input Output Management In C Programming
 
Input and Output Devices
Input and Output DevicesInput and Output Devices
Input and Output Devices
 
5 1. character processing
5 1. character processing5 1. character processing
5 1. character processing
 
CHAPTER 4
CHAPTER 4CHAPTER 4
CHAPTER 4
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functions
 
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
C# .NET: Language Features and Creating .NET Projects, Namespaces Classes and...
 
C presentation book
C presentation bookC presentation book
C presentation book
 
Automotive Circuit Boards
Automotive Circuit BoardsAutomotive Circuit Boards
Automotive Circuit Boards
 
Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)Programming embedded system_ii_keil_8051(1)
Programming embedded system_ii_keil_8051(1)
 
Escape sequences
Escape sequencesEscape sequences
Escape sequences
 
RoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB FabricationRoHS Compliant Lead Free PCB Fabrication
RoHS Compliant Lead Free PCB Fabrication
 
SMT machine Training Manual for FUJI CP6 Series Level 3
SMT machine Training Manual for FUJI  CP6 Series Level 3SMT machine Training Manual for FUJI  CP6 Series Level 3
SMT machine Training Manual for FUJI CP6 Series Level 3
 
Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...
Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...
Pcb Production and Prototype Manufacturing Capabilities for Saturn Electronic...
 
Reflow oven
Reflow ovenReflow oven
Reflow oven
 
pre processor directives in C
pre processor directives in Cpre processor directives in C
pre processor directives in C
 
training_presentation
training_presentationtraining_presentation
training_presentation
 
Epoxy flux a low cost high reliability approach for pop assembly-imaps 2011
Epoxy flux  a low cost high reliability approach for pop assembly-imaps 2011Epoxy flux  a low cost high reliability approach for pop assembly-imaps 2011
Epoxy flux a low cost high reliability approach for pop assembly-imaps 2011
 

Similaire à Basic Input and Output

Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]Abhishek Sinha
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02Wingston
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C LanguageAdnan Khan
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdfSowmyaJyothi3
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’eShikshak
 
Unit 3 Input Output.pptx
Unit 3 Input Output.pptxUnit 3 Input Output.pptx
Unit 3 Input Output.pptxPrecise Mya
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in CMuthuganesh S
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in cniyamathShariff
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
3 character strings and formatted input output
3  character strings and formatted input output3  character strings and formatted input output
3 character strings and formatted input outputMomenMostafa
 
Data Input and Output
Data Input and OutputData Input and Output
Data Input and OutputSabik T S
 

Similaire à Basic Input and Output (20)

Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C Language
 
Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Function
 
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdfMANAGING INPUT AND OUTPUT OPERATIONS IN C    MRS.SOWMYA JYOTHI.pdf
MANAGING INPUT AND OUTPUT OPERATIONS IN C MRS.SOWMYA JYOTHI.pdf
 
Mesics lecture 5 input – output in ‘c’
Mesics lecture 5   input – output in ‘c’Mesics lecture 5   input – output in ‘c’
Mesics lecture 5 input – output in ‘c’
 
string , pointer
string , pointerstring , pointer
string , pointer
 
Unit 3 Input Output.pptx
Unit 3 Input Output.pptxUnit 3 Input Output.pptx
Unit 3 Input Output.pptx
 
Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
String Manipulation Function and Header File Functions
String Manipulation Function and Header File FunctionsString Manipulation Function and Header File Functions
String Manipulation Function and Header File Functions
 
Managing input and output operations in c
Managing input and output operations in cManaging input and output operations in c
Managing input and output operations in c
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
input
inputinput
input
 
Unit 2- Module 2.pptx
Unit 2- Module 2.pptxUnit 2- Module 2.pptx
Unit 2- Module 2.pptx
 
3 character strings and formatted input output
3  character strings and formatted input output3  character strings and formatted input output
3 character strings and formatted input output
 
First c program
First c programFirst c program
First c program
 
Data Input and Output
Data Input and OutputData Input and Output
Data Input and Output
 
Introduction to Input/Output Functions in C
Introduction to Input/Output Functions in CIntroduction to Input/Output Functions in C
Introduction to Input/Output Functions in C
 
String_C.pptx
String_C.pptxString_C.pptx
String_C.pptx
 

Basic Input and Output

  • 1.
  • 2.
  • 3. SCANF &PRINTF Input Statement -> SCANF scanf() is used to give data to variables using keyboard scanf works very well when the viewer’s input has NO spaces Output Statement ->PRINTF printf() is used to show the result of the program trough display device
  • 4. GETS &PUTS Input Statement -> GETS gets() function accepts an entire line of input from the standard input device (keyboard) Output Statement ->PUTS It is complement of gets. Its display a string on the standard output device
  • 5. REVISE LAB 3 Exercise 1 a. #include<stdio.h> #include<conio.h> main() { Enter subject name: Computer Programming char subject[20]; Your name is: Computer printf("Enter subject name:"); scanf("%s", &subject); printf("Your name is: %s n",subject); getch(); } b. #include<stdio.h> #include<conio.h> main() { Enter subject name: Computer Programming char subject[20]; Your name is: printf("Enter a subject name:"); Computer Programming gets(subject); printf("Your name is: n"); puts(subject); getch(); }
  • 6. Cannot read a multi-word string such as computer programming Its read only computer scanf terminates it input when it encounter a blank space such as space, tab, new line, form feed, carriage return. Overcomes the disadvantages of scanf functions It can read any string length with any numbers of blank space
  • 7. GETCHAR &PUTCHAR • Define in the standard C header stdio.h Input Statement -> GETCHAR • getch is used to read a character with pressing the enter Output Statement ->PUTCHAR • Complement of the getchar function • To display a single character on the standard output device
  • 8. GETCH &PUTCH • Accessed from <stdio.h> standard library Input Statement -> GETCH • getch is used to returns a single character typed in from the standard input device Output Statement ->PUTCH • As soon as key is pressed it stop accessing the keyboard. • User don’t have to press the ENTER key.
  • 9. REVISE LAB 3 Exercise 1 c. #include<stdio.h> #include<conio.h> main() { Enter a character: Computer Programming char letter; Your Input is: printf("Enter a character:"); C letter=getchar(); printf("nYour input is: n"); putchar(letter); getch(); } d. #include<stdio.h> #include<conio.h> main() { Enter subject name: char letter; Your name is: printf("Enter a character:"); C letter=getch(); printf("nYour input is: n"); putch(letter); getch(); }
  • 10. What is a STRING?? a string is a character variable with more than one character. Strings can be abbreviations, words, phrases, sentences, or even paragraphs
  • 11. Can be said as : Format specifier Format string
  • 12. Format Output Type Output Specifier Example %d Signed decimal integer 76 %i Signed decimal integer 76 %o Unsigned octal integer 134 %u Unsigned decimal integer 76 %x Unsigned hexadecimal (small letter) 9c %X Unsigned hexadecimal (capital letter) 9C %f Integer including decimal point 76.0000 %e Signed floating point (using e notation) 7.6000e+01 %E Signed floating point (using E notation) 7.6000E+01 %g The shorter between %f and %e 76 %G The shorter between %f and %E 76 %c Character ‘7’ %s String ‘76'
  • 13. Why Use Format Specifier?? Nature of c requires that I/0 operations be associated with specifier data types. This association is made with format and conversion specifiers. When use with the input statements, conversion specifiers tell what kind of variable is being read
  • 14. Example scanf(“%lf”,& x); Tells C to interpret character type at the keyboard as real number of type double
  • 15.
  • 16. Also said as sscape sequences Its allow you to send nongraphic control characters to a display device Basic Constant Effect a Beep sound b Backspace f Formfeed (for printing) n New line r Carriage return t Tab v Vertical tab Backslash ” “ sign o Octal decimal x Hexadecimal O NULL