SlideShare a Scribd company logo
1 of 24
BY
B.ABINAYA BHARATHI M.Sc.,
NSCAS.
INTRODUCTION
Reading , processing and writing are the three main
functions in a program.
For reading and writing we are using two formatted I/O
function
* printf() -for writing
* scanf() -for reading
There are two types of I/O functions
* formatted I/O
* unformatted I/O
Formatted I/O
printf() ~ used to print output to the screen.
SYNTAX:
printf(“format”,var1,var2…);
format represent the text to be displayed or format
specification a or some escape sequence.
Ex: printf(“n A Value : %d “,a);
Escape sequence Text to be
displayed
Format
specification
variable
printf() never proceed in a newline automatically.
printf() also support special format specification.
General form:
%w.p type-specifier
w-total number of columns for a output value.
p-number of digits right side of the decimal.
Example:
printf(“%2d”,a); - for integer value.
printf(“%2.7f”,a); - for real value
printf(“%2c”,a); - for a character
printf(“%2s”,a); - for a string
Commonly used Type specifiers
scanf()- getting input from the user.
SYNTAX:
scanf(“format”,&var);
format represent the what type specifier ?
& represent the where the input to be stored.
var is a variable.
Ex: scanf(“%s”,&a);
Format specifier variable
UNFORMATTED I/O
getchar() - is used to read a single character.
General form:
var_name=getchar ();
putchar() – is used to write a character.
General form:
putchar(var_name);
To read and write a single character we are using
getchar() , putchar() , %c.
To read and write a string we normally use %s . Another
way is gets() and puts().
gets() - This function is used to get a string.
puts() - This function is used to print a string.
General Form:
gets(variable);
puts(variable);
(or)
puts(“sting to be displayed”);
STRING FUNCTIONS
In C there are predefined string functions or string
manipulation.
common string function
* strcat() – combine two strings
* strcmp() – compare two strings
* strcpy() – copy two strings
* strupr() – convert to uppercase
* strlen() – length of the string
* strlwr() – convert to lowercase
<string.h> header file is used to use these string functions.
SYNTAX:
strcat()
strcat(string1,string2);
strcmp()
strcmp(string1,string2);
strcpy()
strcpy(string1,string2);
strupr()
strupr(string1);
strlwr()
strlwr(string1);
strlen()
strlen(string1);
Other string functions
strncpy() - it copies the source string to the destination
string
SYNTAX:
strncpy( dest , source , n);
dest – where the content to be copied.
source – Thus is the string to be copied
n – number of character to be copied from the
source.
strncmp() - compares the first n bytes of string1 and
string2.
SYNTAX:
strncmp(string1,string2,n);
string1 – first string
string2 – second string
n - maximum number of characters to be
compared
strstr() – used to find the substring is present or not.
SYNTAX:
strstr(string1,string2);
strncat() - It is used to combine two strings. combine the
first n bytes of string1 and string2.
strncat(string1,string2,n);
string1 – first string
string2 – second string
n - maximum number of characters to be
combined.
THANK YOU

More Related Content

What's hot

Structures in c language
Structures in c languageStructures in c language
Structures in c languagetanmaymodi4
 
Implementation Of String Functions In C
Implementation Of String Functions In CImplementation Of String Functions In C
Implementation Of String Functions In CFazila Sadia
 
Pointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanPointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanMohammadSalman129
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and OutputAshim Lamichhane
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programmingAppili Vamsi Krishna
 
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothiArrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothiSowmya Jyothi
 
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
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C v_jk
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programmingprogramming9
 
Strings IN C
Strings IN CStrings IN C
Strings IN Cyndaravind
 
String in c programming
String in c programmingString in c programming
String in c programmingDevan Thakur
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Languagemadan reddy
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array pptsandhya yadav
 
R basics
R basicsR basics
R basicsFAO
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c languageTanmay Modi
 

What's hot (20)

Structures in c language
Structures in c languageStructures in c language
Structures in c language
 
Implementation Of String Functions In C
Implementation Of String Functions In CImplementation Of String Functions In C
Implementation Of String Functions In C
 
Pointers in c - Mohammad Salman
Pointers in c - Mohammad SalmanPointers in c - Mohammad Salman
Pointers in c - Mohammad Salman
 
Unit 3. Input and Output
Unit 3. Input and OutputUnit 3. Input and Output
Unit 3. Input and Output
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Handling of character strings C programming
Handling of character strings C programmingHandling of character strings C programming
Handling of character strings C programming
 
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothiArrays in c unit iii chapter 1 mrs.sowmya jyothi
Arrays in c unit iii chapter 1 mrs.sowmya jyothi
 
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
 
RECURSION IN C
RECURSION IN C RECURSION IN C
RECURSION IN C
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
 
Strings IN C
Strings IN CStrings IN C
Strings IN C
 
Strings
StringsStrings
Strings
 
Pointers in C
Pointers in CPointers in C
Pointers in C
 
String in c programming
String in c programmingString in c programming
String in c programming
 
Pointers in C Language
Pointers in C LanguagePointers in C Language
Pointers in C Language
 
Unions in c
Unions in cUnions in c
Unions in c
 
Python programming : List and tuples
Python programming : List and tuplesPython programming : List and tuples
Python programming : List and tuples
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
R basics
R basicsR basics
R basics
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
 

Similar to Formatted and Unformatted I/O Functions in C

Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio Bhavik Vashi
 
Input And Output
 Input And Output Input And Output
Input And OutputGhaffar Khan
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlabMohan Raj
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and stringsRai University
 
CHAPTER 4
CHAPTER 4CHAPTER 4
CHAPTER 4mohd_mizan
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 FocJAYA
 
Format string
Format stringFormat string
Format stringVu Review
 
T03 b basicioscanf
T03 b basicioscanfT03 b basicioscanf
T03 b basicioscanfteach4uin
 
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
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsRai University
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++Muhammad Hammad Waseem
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and stringsRai University
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsRai University
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-aneebkmct
 

Similar to Formatted and Unformatted I/O Functions in C (20)

Functions of stdio conio
Functions of stdio   conio Functions of stdio   conio
Functions of stdio conio
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
 
Input And Output
 Input And Output Input And Output
Input And Output
 
Chap 8(strings)
Chap 8(strings)Chap 8(strings)
Chap 8(strings)
 
C q 3
C q 3C q 3
C q 3
 
Tut1
Tut1Tut1
Tut1
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Diploma ii cfpc u-4 function, storage class and array and strings
Diploma ii  cfpc u-4 function, storage class and array and stringsDiploma ii  cfpc u-4 function, storage class and array and strings
Diploma ii cfpc u-4 function, storage class and array and strings
 
CHAPTER 4
CHAPTER 4CHAPTER 4
CHAPTER 4
 
Lecture 8- Data Input and Output
Lecture 8- Data Input and OutputLecture 8- Data Input and Output
Lecture 8- Data Input and Output
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
Format string
Format stringFormat string
Format string
 
T03 b basicioscanf
T03 b basicioscanfT03 b basicioscanf
T03 b basicioscanf
 
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 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
 
Mcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and stringsMcai pic u 4 function, storage class and array and strings
Mcai pic u 4 function, storage class and array and strings
 
[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
function, storage class and array and strings
 function, storage class and array and strings function, storage class and array and strings
function, storage class and array and strings
 
Btech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and stringsBtech i pic u-4 function, storage class and array and strings
Btech i pic u-4 function, storage class and array and strings
 
Functions torage class and array and strings-
Functions torage class and array and strings-Functions torage class and array and strings-
Functions torage class and array and strings-
 

More from Abinaya B

Multimedia
MultimediaMultimedia
MultimediaAbinaya B
 
Overview of bigdata
Overview of bigdataOverview of bigdata
Overview of bigdataAbinaya B
 
exception handling in java
exception handling in javaexception handling in java
exception handling in javaAbinaya B
 
data structures
data structuresdata structures
data structuresAbinaya B
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in javaAbinaya B
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back trackingAbinaya B
 
exception handling in java
exception handling in javaexception handling in java
exception handling in javaAbinaya B
 
digital image processing
digital image processingdigital image processing
digital image processingAbinaya B
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processingAbinaya B
 
software engineering
software engineeringsoftware engineering
software engineeringAbinaya B
 
software cost factor
software cost factorsoftware cost factor
software cost factorAbinaya B
 
Data Mining
Data MiningData Mining
Data MiningAbinaya B
 
Datamining
DataminingDatamining
DataminingAbinaya B
 
Basic topic on os
Basic topic on osBasic topic on os
Basic topic on osAbinaya B
 
Digital principles basic
Digital principles basicDigital principles basic
Digital principles basicAbinaya B
 
Rdbms1
Rdbms1Rdbms1
Rdbms1Abinaya B
 
Introduction to 80386
Introduction to 80386Introduction to 80386
Introduction to 80386Abinaya B
 
Network standardization
Network standardizationNetwork standardization
Network standardizationAbinaya B
 

More from Abinaya B (18)

Multimedia
MultimediaMultimedia
Multimedia
 
Overview of bigdata
Overview of bigdataOverview of bigdata
Overview of bigdata
 
exception handling in java
exception handling in javaexception handling in java
exception handling in java
 
data structures
data structuresdata structures
data structures
 
graphics programming in java
graphics programming in javagraphics programming in java
graphics programming in java
 
data structures- back tracking
data structures- back trackingdata structures- back tracking
data structures- back tracking
 
exception handling in java
exception handling in javaexception handling in java
exception handling in java
 
digital image processing
digital image processingdigital image processing
digital image processing
 
Image filtering in Digital image processing
Image filtering in Digital image processingImage filtering in Digital image processing
Image filtering in Digital image processing
 
software engineering
software engineeringsoftware engineering
software engineering
 
software cost factor
software cost factorsoftware cost factor
software cost factor
 
Data Mining
Data MiningData Mining
Data Mining
 
Datamining
DataminingDatamining
Datamining
 
Basic topic on os
Basic topic on osBasic topic on os
Basic topic on os
 
Digital principles basic
Digital principles basicDigital principles basic
Digital principles basic
 
Rdbms1
Rdbms1Rdbms1
Rdbms1
 
Introduction to 80386
Introduction to 80386Introduction to 80386
Introduction to 80386
 
Network standardization
Network standardizationNetwork standardization
Network standardization
 

Recently uploaded

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
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
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
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
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 

Recently uploaded (20)

Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
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
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
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
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
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
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
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
 
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
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 

Formatted and Unformatted I/O Functions in C

  • 2. INTRODUCTION Reading , processing and writing are the three main functions in a program. For reading and writing we are using two formatted I/O function * printf() -for writing * scanf() -for reading There are two types of I/O functions * formatted I/O * unformatted I/O
  • 3. Formatted I/O printf() ~ used to print output to the screen. SYNTAX: printf(“format”,var1,var2…); format represent the text to be displayed or format specification a or some escape sequence. Ex: printf(“n A Value : %d “,a); Escape sequence Text to be displayed Format specification variable
  • 4. printf() never proceed in a newline automatically. printf() also support special format specification. General form: %w.p type-specifier w-total number of columns for a output value. p-number of digits right side of the decimal. Example: printf(“%2d”,a); - for integer value. printf(“%2.7f”,a); - for real value printf(“%2c”,a); - for a character printf(“%2s”,a); - for a string
  • 5. Commonly used Type specifiers
  • 6. scanf()- getting input from the user. SYNTAX: scanf(“format”,&var); format represent the what type specifier ? & represent the where the input to be stored. var is a variable. Ex: scanf(“%s”,&a); Format specifier variable
  • 7.
  • 8.
  • 9. UNFORMATTED I/O getchar() - is used to read a single character. General form: var_name=getchar (); putchar() – is used to write a character. General form: putchar(var_name);
  • 10.
  • 11.
  • 12. To read and write a single character we are using getchar() , putchar() , %c. To read and write a string we normally use %s . Another way is gets() and puts(). gets() - This function is used to get a string. puts() - This function is used to print a string. General Form: gets(variable); puts(variable); (or) puts(“sting to be displayed”);
  • 13.
  • 14.
  • 15. STRING FUNCTIONS In C there are predefined string functions or string manipulation. common string function * strcat() – combine two strings * strcmp() – compare two strings * strcpy() – copy two strings * strupr() – convert to uppercase * strlen() – length of the string * strlwr() – convert to lowercase <string.h> header file is used to use these string functions.
  • 17.
  • 18.
  • 19. Other string functions strncpy() - it copies the source string to the destination string SYNTAX: strncpy( dest , source , n); dest – where the content to be copied. source – Thus is the string to be copied n – number of character to be copied from the source.
  • 20. strncmp() - compares the first n bytes of string1 and string2. SYNTAX: strncmp(string1,string2,n); string1 – first string string2 – second string n - maximum number of characters to be compared strstr() – used to find the substring is present or not. SYNTAX: strstr(string1,string2);
  • 21. strncat() - It is used to combine two strings. combine the first n bytes of string1 and string2. strncat(string1,string2,n); string1 – first string string2 – second string n - maximum number of characters to be combined.
  • 22.
  • 23.