SlideShare une entreprise Scribd logo
1  sur  17
PRINTF(), SCANF()
CONVERSION SPECIFIERS
ESCAPE SEQUENCES
Input Output Management
Compiled By: Kamal Acharya
INPUT and OUTPUT
Compiled By: Kamal Acharya
 printf() will print formatted output to the screen.
 To print a message:
printf("This is a messagen");
 How do we print the value of a variable?
 Answer: Use special format specifiers depending on the type of
the variable
this is a string literal
Printing Output: printf()
Compiled By: Kamal Acharya
Compiled By: Kamal Acharya
int degreesF = 68;
printf("The temperature is %d degrees.", degreesF);
Specifier for
“print an integer value”
“and the value of
that number is read
from this variable”
> The temperature is 68 degrees.
Output:
Compiled By: Kamal Acharya
int a = 1;
int b = 2;
int c = 3;
printf(“%d plus %d is equal to %d", a, b, c);
1 plus 2 is equal to 3
Output:
Compiled By: Kamal Acharya
 Format specifiers:
 %c for single characters
 %d for integers
 %f for float/double (fractions): 1234.56
 %g for float/double (scientific): 1.23456E+3
 %s for phrases or ‘strings’
Compiled By: Kamal Acharya
Output:
A 65 41 101
Example:
char a='A';
printf("%c %d %x %0", a, a, a, a);
Compiled By: Kamal Acharya
Format specifier can be used with modifiers
Example :
%-6d, %5d, %6.2f
Modifier
digit
Description
Allocate minimum width (in characters).
.digit Number of floating-points
- left justified
l Print the data as a long integer.
Compiled By: Kamal Acharya
Statement Output
printf("|%d|", 987); |987|
printf("|%2d|", 987); |987|
printf("|%8d|", 987); | 987|
printf("|%-8d|", 987); |987 |
printf("|%0.2f|", 9876.54); |9876.54|
printf("|%4.2f|", 9876.54); |9876.54|
printf("|%3.1f|", 9876.54); |9876.5|
printf("|%10.3f|", 9876.54); | 9876.540|
Compiled By: Kamal Acharya
printf(“Hello n World!");
Hello
World!
Output:
‘n’ is not a data to be printed. Instead, it is a command that tells the
monitor to move the cursor to the next line
Compiled By: Kamal Acharya
Control Characters (Escape Sequences)
Character
'n'
't'
'v'
'r'
'x41'
'101'
'0'
'''
'"'
''
'b'
'f'
'a'
Description
newline
horizontal tab
vertical tab
carriage return
hexadecimal number, 0x41
octal number 101
null character - indicates the end of a string
single quatation mark (')
double quatation mark (")
backslash mark ()
backspace
formfeed - next page (used for printer)
alert - produce a beep sound
Compiled By: Kamal Acharya
Figure: Output specification for inventory report
printf (“Part NumbertQty On HandtQty On OrderttPricen”);
t t tt n
Compiled By: Kamal Acharya
Keyboard input: scanf()
 scanf() will scan formatted input from the keyboard.
 It uses the same format specifiers as printf()
 To read an integer:
 int num_students;
scanf("%d", &num_students);
Specifier for
“reading an integer value”
VERY IMPORTANT
special symbol
“Place value into this
variable”
Compiled By: Kamal Acharya
Compiled By: Kamal Acharya
Format specifiers for scanf()
 Format specifiers:
 %c for single characters
 scanf(" %c", &some_character);
 %d for integers
 scanf ("%d", &some_integer);
 %f for float
 scanf ("%f", &some_float);
 %lf for double
 scanf ("%lf", &some_double);
always put a space between " and % when reading characters
Compiled By: Kamal Acharya
Escape Sequences
Compiled By: Kamal Acharya

Contenu connexe

Tendances

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
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
Sahithi Naraparaju
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
Jeya Lakshmi
 

Tendances (20)

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
 
File in C language
File in C languageFile in C language
File in C language
 
Data Input and Output
Data Input and OutputData Input and Output
Data Input and Output
 
String functions in C
String functions in CString functions in C
String functions in C
 
String in c programming
String in c programmingString in c programming
String in c programming
 
Strings in c
Strings in cStrings in c
Strings in c
 
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’
 
Learn C
Learn CLearn C
Learn C
 
Character Array and String
Character Array and StringCharacter Array and String
Character Array and String
 
Function in C Programming
Function in C ProgrammingFunction in C Programming
Function in C Programming
 
Function in C
Function in CFunction in C
Function in C
 
Input And Output
 Input And Output Input And Output
Input And Output
 
C string
C stringC string
C string
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
constants, variables and datatypes in C
constants, variables and datatypes in Cconstants, variables and datatypes in C
constants, variables and datatypes in C
 
Strings
StringsStrings
Strings
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
 
Enums in c
Enums in cEnums in c
Enums in c
 
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
C-Programming  C LIBRARIES AND USER DEFINED LIBRARIES.pptxC-Programming  C LIBRARIES AND USER DEFINED LIBRARIES.pptx
C-Programming C LIBRARIES AND USER DEFINED LIBRARIES.pptx
 
C language
C languageC language
C language
 

En vedette

Input and output in c
Input and output in cInput and output in c
Input and output in c
Rachana Joshi
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
Anil Dutt
 

En vedette (20)

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
 
Managing console
Managing consoleManaging console
Managing console
 
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...
 
File handling-dutt
File handling-duttFile handling-dutt
File handling-dutt
 
C chap02
C chap02C chap02
C chap02
 
Module 03 File Handling in C
Module 03 File Handling in CModule 03 File Handling in C
Module 03 File Handling in C
 
[UX Project] C-Saw
[UX Project] C-Saw[UX Project] C-Saw
[UX Project] C-Saw
 
Structure of c_program_to_input_output
Structure of c_program_to_input_outputStructure of c_program_to_input_output
Structure of c_program_to_input_output
 
Ponters
PontersPonters
Ponters
 
IO Management
IO ManagementIO Management
IO Management
 
File handling in C
File handling in CFile handling in C
File handling in C
 
File handling in 'C'
File handling in 'C'File handling in 'C'
File handling in 'C'
 
Pointers
PointersPointers
Pointers
 
Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
C pointer
C pointerC pointer
C pointer
 
Slide share
Slide shareSlide share
Slide share
 
Input Output Organization
Input Output OrganizationInput Output Organization
Input Output Organization
 
Basics of telecommunication and networking
Basics of telecommunication and networkingBasics of telecommunication and networking
Basics of telecommunication and networking
 

Similaire à Input Output Management In C Programming

Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
Hanielle Cheng
 

Similaire à Input Output Management In C Programming (20)

input
inputinput
input
 
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’
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Cse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingCse115 lecture04introtoc programming
Cse115 lecture04introtoc programming
 
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
 
week-3x
week-3xweek-3x
week-3x
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
Najmul
Najmul  Najmul
Najmul
 
C programs
C programsC programs
C programs
 
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
 
C-programs
C-programsC-programs
C-programs
 
Introduction to Basic C programming 02
Introduction to Basic C programming 02Introduction to Basic C programming 02
Introduction to Basic C programming 02
 
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
 
Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
 
Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
 
Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
 
Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
 
Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
 
Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
 
Introduction to turbo c
Introduction to turbo cIntroduction to turbo c
Introduction to turbo c
 

Plus de Kamal Acharya

Plus de Kamal Acharya (20)

Programming the basic computer
Programming the basic computerProgramming the basic computer
Programming the basic computer
 
Computer Arithmetic
Computer ArithmeticComputer Arithmetic
Computer Arithmetic
 
Introduction to Computer Security
Introduction to Computer SecurityIntroduction to Computer Security
Introduction to Computer Security
 
Session and Cookies
Session and CookiesSession and Cookies
Session and Cookies
 
Functions in php
Functions in phpFunctions in php
Functions in php
 
Web forms in php
Web forms in phpWeb forms in php
Web forms in php
 
Making decision and repeating in PHP
Making decision and repeating  in PHPMaking decision and repeating  in PHP
Making decision and repeating in PHP
 
Working with arrays in php
Working with arrays in phpWorking with arrays in php
Working with arrays in php
 
Text and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHPText and Numbers (Data Types)in PHP
Text and Numbers (Data Types)in PHP
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
Capacity Planning of Data Warehousing
Capacity Planning of Data WarehousingCapacity Planning of Data Warehousing
Capacity Planning of Data Warehousing
 
Data Warehousing
Data WarehousingData Warehousing
Data Warehousing
 
Search Engines
Search EnginesSearch Engines
Search Engines
 
Web Mining
Web MiningWeb Mining
Web Mining
 
Information Privacy and Data Mining
Information Privacy and Data MiningInformation Privacy and Data Mining
Information Privacy and Data Mining
 
Cluster Analysis
Cluster AnalysisCluster Analysis
Cluster Analysis
 
Association Analysis in Data Mining
Association Analysis in Data MiningAssociation Analysis in Data Mining
Association Analysis in Data Mining
 
Classification techniques in data mining
Classification techniques in data miningClassification techniques in data mining
Classification techniques in data mining
 
Data Preprocessing
Data PreprocessingData Preprocessing
Data Preprocessing
 
Introduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data WarehousingIntroduction to Data Mining and Data Warehousing
Introduction to Data Mining and Data Warehousing
 

Dernier

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
PECB
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
negromaestrong
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Dernier (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural ResourcesEnergy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
Energy Resources. ( B. Pharmacy, 1st Year, Sem-II) Natural Resources
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-IIFood Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
Food Chain and Food Web (Ecosystem) EVS, B. Pharmacy 1st Year, Sem-II
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 

Input Output Management In C Programming

  • 1. PRINTF(), SCANF() CONVERSION SPECIFIERS ESCAPE SEQUENCES Input Output Management Compiled By: Kamal Acharya
  • 2. INPUT and OUTPUT Compiled By: Kamal Acharya
  • 3.  printf() will print formatted output to the screen.  To print a message: printf("This is a messagen");  How do we print the value of a variable?  Answer: Use special format specifiers depending on the type of the variable this is a string literal Printing Output: printf() Compiled By: Kamal Acharya
  • 5. int degreesF = 68; printf("The temperature is %d degrees.", degreesF); Specifier for “print an integer value” “and the value of that number is read from this variable” > The temperature is 68 degrees. Output: Compiled By: Kamal Acharya
  • 6. int a = 1; int b = 2; int c = 3; printf(“%d plus %d is equal to %d", a, b, c); 1 plus 2 is equal to 3 Output: Compiled By: Kamal Acharya
  • 7.  Format specifiers:  %c for single characters  %d for integers  %f for float/double (fractions): 1234.56  %g for float/double (scientific): 1.23456E+3  %s for phrases or ‘strings’ Compiled By: Kamal Acharya
  • 8. Output: A 65 41 101 Example: char a='A'; printf("%c %d %x %0", a, a, a, a); Compiled By: Kamal Acharya
  • 9. Format specifier can be used with modifiers Example : %-6d, %5d, %6.2f Modifier digit Description Allocate minimum width (in characters). .digit Number of floating-points - left justified l Print the data as a long integer. Compiled By: Kamal Acharya
  • 10. Statement Output printf("|%d|", 987); |987| printf("|%2d|", 987); |987| printf("|%8d|", 987); | 987| printf("|%-8d|", 987); |987 | printf("|%0.2f|", 9876.54); |9876.54| printf("|%4.2f|", 9876.54); |9876.54| printf("|%3.1f|", 9876.54); |9876.5| printf("|%10.3f|", 9876.54); | 9876.540| Compiled By: Kamal Acharya
  • 11. printf(“Hello n World!"); Hello World! Output: ‘n’ is not a data to be printed. Instead, it is a command that tells the monitor to move the cursor to the next line Compiled By: Kamal Acharya
  • 12. Control Characters (Escape Sequences) Character 'n' 't' 'v' 'r' 'x41' '101' '0' ''' '"' '' 'b' 'f' 'a' Description newline horizontal tab vertical tab carriage return hexadecimal number, 0x41 octal number 101 null character - indicates the end of a string single quatation mark (') double quatation mark (") backslash mark () backspace formfeed - next page (used for printer) alert - produce a beep sound Compiled By: Kamal Acharya
  • 13. Figure: Output specification for inventory report printf (“Part NumbertQty On HandtQty On OrderttPricen”); t t tt n Compiled By: Kamal Acharya
  • 14. Keyboard input: scanf()  scanf() will scan formatted input from the keyboard.  It uses the same format specifiers as printf()  To read an integer:  int num_students; scanf("%d", &num_students); Specifier for “reading an integer value” VERY IMPORTANT special symbol “Place value into this variable” Compiled By: Kamal Acharya
  • 16. Format specifiers for scanf()  Format specifiers:  %c for single characters  scanf(" %c", &some_character);  %d for integers  scanf ("%d", &some_integer);  %f for float  scanf ("%f", &some_float);  %lf for double  scanf ("%lf", &some_double); always put a space between " and % when reading characters Compiled By: Kamal Acharya