SlideShare a Scribd company logo
1 of 15
Download to read offline
Computer Programming
IN-Put Statements
DIT Part 1
Lecture 7
IN-Put Statement
• An input/output statement or io statement is
a portion of a program that instructs a
computer how to read and process
information.
• It use to gather information from an input
device, or sending information to an output
device.
Copyrights By Tanveer Malik
IN-Put Statements
• Scanf () Function.
• Gets() Function.
• Getchar(), getch(), and getch Function.
• Input using Cin
Copyrights By Tanveer Malik
Scanf()
• Scanf is a inbuilt library functions in C
programming language which is available in C
library by default.
• In C programming language, scanf() function is
used to read character, string, numeric data
from keyboard.
• Consider below example program where user
enters a character. This value is assigned to
the variable “ch” and then displayed.
Copyrights By Tanveer Malik
Scanf()
Copyrights By Tanveer Malik
Gets()
• The C library function char *gets(char *str)
reads a line from stdin and stores it into the
string pointed to by str.
• It stops when either the newline character is
read or when the end-of-file is reached,
whichever comes first.
Copyrights By Tanveer Malik
Gets()
Copyrights By Tanveer Malik
Getc()
• It reads a single character from a given input
stream and returns the corresponding integer
value on success.
Syntax:
• int getc(FILE *stream);
Copyrights By Tanveer Malik
Getc()
Copyrights By Tanveer Malik
Getchar()
• The difference between getc() and getchar() is
getc() can read from any input stream,
• but getchar() reads from standard input.
• So getchar() is equivalent to getc(stdin).
Syntax:
• int getchar(void);
Copyrights By Tanveer Malik
Getchar()
Copyrights By Tanveer Malik
Getch()
• getch() is a nonstandard function.
• It is present in conio.h header file.
• Which is mostly used by MS-DOS compilers
like Turbo C.
Syntax:
• int getch();
Copyrights By Tanveer Malik
Getch()
Copyrights By Tanveer Malik
Assignment
– Any input-statement
Program.
Lecture 7

More Related Content

What's hot (20)

Lesson 5.2 logical operators
Lesson 5.2 logical operatorsLesson 5.2 logical operators
Lesson 5.2 logical operators
 
C++ unit-1-part-10
C++ unit-1-part-10C++ unit-1-part-10
C++ unit-1-part-10
 
Python algorithm
Python algorithmPython algorithm
Python algorithm
 
Peephole optimization techniques in compiler design
Peephole optimization techniques in compiler designPeephole optimization techniques in compiler design
Peephole optimization techniques in compiler design
 
Code Optimization
Code OptimizationCode Optimization
Code Optimization
 
Python recursion
Python recursionPython recursion
Python recursion
 
Issues in design_of_code_generator
Issues in design_of_code_generatorIssues in design_of_code_generator
Issues in design_of_code_generator
 
Compiler construction tools
Compiler construction toolsCompiler construction tools
Compiler construction tools
 
Programming in c (importance of c)
Programming in c (importance of c)Programming in c (importance of c)
Programming in c (importance of c)
 
Supporting Arrays and Allocatables in LFortran
Supporting Arrays and Allocatables in LFortranSupporting Arrays and Allocatables in LFortran
Supporting Arrays and Allocatables in LFortran
 
Toy compiler
Toy compilerToy compiler
Toy compiler
 
Function in c programming
Function in c programmingFunction in c programming
Function in c programming
 
Compiler design
Compiler designCompiler design
Compiler design
 
Lesson 13 object and class
Lesson 13 object and classLesson 13 object and class
Lesson 13 object and class
 
Code Generation
Code GenerationCode Generation
Code Generation
 
Lesson 1 introduction to programming
Lesson 1 introduction to programmingLesson 1 introduction to programming
Lesson 1 introduction to programming
 
Code optimization
Code optimizationCode optimization
Code optimization
 
Toy complier
Toy complierToy complier
Toy complier
 
Optimization
OptimizationOptimization
Optimization
 
Optimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGAOptimized Floating-point Complex number multiplier on FPGA
Optimized Floating-point Complex number multiplier on FPGA
 

Similar to Lecture 7

Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptxchouguleamruta24
 
FILE OPERATIONS.pptx
FILE OPERATIONS.pptxFILE OPERATIONS.pptx
FILE OPERATIONS.pptxDeepasCSE
 
Embedded c & working with avr studio
Embedded c & working with avr studioEmbedded c & working with avr studio
Embedded c & working with avr studioNitesh Singh
 
0-Slot14-15-16-Libraries.pdf
0-Slot14-15-16-Libraries.pdf0-Slot14-15-16-Libraries.pdf
0-Slot14-15-16-Libraries.pdfssusere19c741
 
Basics of c Nisarg Patel
Basics of c Nisarg PatelBasics of c Nisarg Patel
Basics of c Nisarg PatelTechNGyan
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compileradilmehmood93
 
Python Basis Tutorial
Python Basis TutorialPython Basis Tutorial
Python Basis Tutorialmd sathees
 
Computer network in java
Computer network in java Computer network in java
Computer network in java YasirAli74993
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malikOshal Shah
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malikOshal Shah
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malikOshal Shah
 
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdfConcisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdffeelinggift
 
Computer programming and utilization
Computer programming and utilizationComputer programming and utilization
Computer programming and utilizationDigvijaysinh Gohil
 

Similar to Lecture 7 (20)

CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
COM1407: Input/ Output Functions
COM1407: Input/ Output FunctionsCOM1407: Input/ Output Functions
COM1407: Input/ Output Functions
 
Lecture 6
Lecture 6Lecture 6
Lecture 6
 
Computer Programming In C.pptx
Computer Programming In C.pptxComputer Programming In C.pptx
Computer Programming In C.pptx
 
FILE OPERATIONS.pptx
FILE OPERATIONS.pptxFILE OPERATIONS.pptx
FILE OPERATIONS.pptx
 
Embedded c & working with avr studio
Embedded c & working with avr studioEmbedded c & working with avr studio
Embedded c & working with avr studio
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
0-Slot14-15-16-Libraries.pdf
0-Slot14-15-16-Libraries.pdf0-Slot14-15-16-Libraries.pdf
0-Slot14-15-16-Libraries.pdf
 
DSA 103 Object Oriented Programming :: Week 4
DSA 103 Object Oriented Programming :: Week 4DSA 103 Object Oriented Programming :: Week 4
DSA 103 Object Oriented Programming :: Week 4
 
Basics of c Nisarg Patel
Basics of c Nisarg PatelBasics of c Nisarg Patel
Basics of c Nisarg Patel
 
what is compiler and five phases of compiler
what is compiler and five phases of compilerwhat is compiler and five phases of compiler
what is compiler and five phases of compiler
 
Python Basis Tutorial
Python Basis TutorialPython Basis Tutorial
Python Basis Tutorial
 
Lecture 8- Data Input and Output
Lecture 8- Data Input and OutputLecture 8- Data Input and Output
Lecture 8- Data Input and Output
 
Computer network in java
Computer network in java Computer network in java
Computer network in java
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malik
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malik
 
Chapter 3 malik
Chapter 3 malikChapter 3 malik
Chapter 3 malik
 
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdfConcisely describe the following terms 40 1. Source code 2. Object c.pdf
Concisely describe the following terms 40 1. Source code 2. Object c.pdf
 
C for Engineers
C for EngineersC for Engineers
C for Engineers
 
Computer programming and utilization
Computer programming and utilizationComputer programming and utilization
Computer programming and utilization
 

More from Tanveer Malik

Lecture 12 security policy
Lecture 12 security policyLecture 12 security policy
Lecture 12 security policyTanveer Malik
 
Lecture 11 active directory
Lecture 11 active directoryLecture 11 active directory
Lecture 11 active directoryTanveer Malik
 
Lecture 10 i pv4 & ipv6
Lecture 10 i pv4 & ipv6Lecture 10 i pv4 & ipv6
Lecture 10 i pv4 & ipv6Tanveer Malik
 
Lecture 9 file system
Lecture 9 file systemLecture 9 file system
Lecture 9 file systemTanveer Malik
 
Lecture 8 disk management
Lecture 8 disk managementLecture 8 disk management
Lecture 8 disk managementTanveer Malik
 
Lecture 6 internet services in network
Lecture 6 internet services in networkLecture 6 internet services in network
Lecture 6 internet services in networkTanveer Malik
 
Lecture 5 software to control network
Lecture 5 software to control networkLecture 5 software to control network
Lecture 5 software to control networkTanveer Malik
 
Lecture 4 sharing of resources on network
Lecture 4 sharing of resources on networkLecture 4 sharing of resources on network
Lecture 4 sharing of resources on networkTanveer Malik
 
Lecture 3 transmission media
Lecture 3 transmission mediaLecture 3 transmission media
Lecture 3 transmission mediaTanveer Malik
 
Lecture 2 protocol details
Lecture 2 protocol detailsLecture 2 protocol details
Lecture 2 protocol detailsTanveer Malik
 
Lecture 1 networking types roles
Lecture 1 networking types rolesLecture 1 networking types roles
Lecture 1 networking types rolesTanveer Malik
 

More from Tanveer Malik (20)

Lecture 12 security policy
Lecture 12 security policyLecture 12 security policy
Lecture 12 security policy
 
Lecture 11 active directory
Lecture 11 active directoryLecture 11 active directory
Lecture 11 active directory
 
Lecture 10 i pv4 & ipv6
Lecture 10 i pv4 & ipv6Lecture 10 i pv4 & ipv6
Lecture 10 i pv4 & ipv6
 
Lecture 9 file system
Lecture 9 file systemLecture 9 file system
Lecture 9 file system
 
Lecture 8 disk management
Lecture 8 disk managementLecture 8 disk management
Lecture 8 disk management
 
Lecture 6 internet services in network
Lecture 6 internet services in networkLecture 6 internet services in network
Lecture 6 internet services in network
 
Lecture 5 software to control network
Lecture 5 software to control networkLecture 5 software to control network
Lecture 5 software to control network
 
Lecture 4 sharing of resources on network
Lecture 4 sharing of resources on networkLecture 4 sharing of resources on network
Lecture 4 sharing of resources on network
 
Lecture 3 transmission media
Lecture 3 transmission mediaLecture 3 transmission media
Lecture 3 transmission media
 
Lecture 2 protocol details
Lecture 2 protocol detailsLecture 2 protocol details
Lecture 2 protocol details
 
Lecture 1 networking types roles
Lecture 1 networking types rolesLecture 1 networking types roles
Lecture 1 networking types roles
 
Lecture 12
Lecture 12Lecture 12
Lecture 12
 
Lecture 11
Lecture 11Lecture 11
Lecture 11
 
Lecture 10
Lecture 10Lecture 10
Lecture 10
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Lecture 8
Lecture 8Lecture 8
Lecture 8
 
Lecture 5
Lecture 5Lecture 5
Lecture 5
 
Lecture 4
Lecture 4Lecture 4
Lecture 4
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 

Recently uploaded

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsanshu789521
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 

Recently uploaded (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Presiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha electionsPresiding Officer Training module 2024 lok sabha elections
Presiding Officer Training module 2024 lok sabha elections
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 

Lecture 7

  • 2. IN-Put Statement • An input/output statement or io statement is a portion of a program that instructs a computer how to read and process information. • It use to gather information from an input device, or sending information to an output device. Copyrights By Tanveer Malik
  • 3. IN-Put Statements • Scanf () Function. • Gets() Function. • Getchar(), getch(), and getch Function. • Input using Cin Copyrights By Tanveer Malik
  • 4. Scanf() • Scanf is a inbuilt library functions in C programming language which is available in C library by default. • In C programming language, scanf() function is used to read character, string, numeric data from keyboard. • Consider below example program where user enters a character. This value is assigned to the variable “ch” and then displayed. Copyrights By Tanveer Malik
  • 6. Gets() • The C library function char *gets(char *str) reads a line from stdin and stores it into the string pointed to by str. • It stops when either the newline character is read or when the end-of-file is reached, whichever comes first. Copyrights By Tanveer Malik
  • 8. Getc() • It reads a single character from a given input stream and returns the corresponding integer value on success. Syntax: • int getc(FILE *stream); Copyrights By Tanveer Malik
  • 10. Getchar() • The difference between getc() and getchar() is getc() can read from any input stream, • but getchar() reads from standard input. • So getchar() is equivalent to getc(stdin). Syntax: • int getchar(void); Copyrights By Tanveer Malik
  • 12. Getch() • getch() is a nonstandard function. • It is present in conio.h header file. • Which is mostly used by MS-DOS compilers like Turbo C. Syntax: • int getch(); Copyrights By Tanveer Malik