SlideShare a Scribd company logo
Input and Output A Lecture by  Abdul ghaffar Khan Chapter #. 6
Input and Output Input: Input is a process of entering the data ito the computer’s memory Output: Output is a process of translating data that are in machine-readable form into a form understandable by humans or readable by other machines.
I/O Functions Character I/O getchar() & putchar() Formatted I/O printf() and scanf() String I/O gets() and puts() Note :  To use any of these function first include the  appropriate  header file in your program.
Character I/O getchar() function getchar() function is used to enter a single character through the standard input device generally keyboard . The syntax of the function is  variable = getchar()
Character I/O putchar() function putchar() function displays a character on the screen. This function takes a character as an argument.The syntax of the function is  putchar( variable )
Character I/O Example 6.1 #include <stdio.h> #include <ctype.h> void main ( void ) { char grade; printf(“Type a character? “); grade = getchar(); grade=toupper(grade); printf(“Your grade is  “); putchar(grade); }
Formatted I/O  Formatted I/O means to control the type, width, precision  and other attribute of the data during input and output process. Two functions are mostly used in C language for this purpose are  printf() scanf()
Formatted I/O Printf Function: printf is function used to output any type of data either characters, strings, numbers etc.. The syntax of printf function is  printf(format_string, var1, var2,….varn);
Printf Function Format string The format string is a character string that may contain two types of elements Plain text Any plain text included in the format string displayed on the screen as it is except Escape Sequence Characters and Format Specifiers. Format Specifiers. Format Specifiers are instructions to the function to  display a data in a specific format. (continue….)
Printf Function The syntax of one format specifier is as follows % [flag] [width] [.prec] conversion_char in a format string there may be any number of format specifiers.  Flags (optional) -  ,  left justifies the result +  ,  always puts a sign before a number depending on the number blank   ,  positive value will have a space before  it  and negative    number will have a minus sign before the number. Width (optional)   This is an integer value which  specifies  the minimum width of the data. (continue..)
Printf Function Precision (optional) Is an integer number to specify the number of decimal places to be displayed in the output for a floating point number. Conversion character (format specifier) There are as many conversion characters as the standard data types are in the ‘C’ language some of those are listed below d sign decimal integer u unsigned decimal integer id  long f floating point e  floating with exponent o octal integer x hexadecimal c  single character s string (multiple characters) (continue…)
Printf Function Variable list The second argument of the function is a list of variables. Here variables , values and expressions can be used to supply the value to the function too display. Example 6.2: int x=34; float y=45.34; char c =‘F’; char  s[] = “this is a string”; Printf(“ Output is %d \t %c \t %f  \t %s \n”,x,c,y,s); Output is 34 F 45.340000 this is a string
Example 6.3 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int roll_no = 450, marks=760; float per,total= 900.0; char section = 'B'; per  = (marks / total) *100.0; printf(&quot;Rol1 Number %d\n&quot;,roll_no); printf(&quot;Section %c\n&quot;,section); printf(&quot;You Secure %d marks out of %f marks\n&quot;, marks, total); printf (&quot;Percentage %f\n&quot;,per); getch(); } Output: Rol1 Number 450 Section B You Secure 760 marks out of 900 marks Percentage 84.444443
Example 6.4 #include <stdio.h> #include <conio.h> void main(void) { int sum = 29766; float radius = 3.7654; clrscr(); printf(&quot;Sum=%2d\n&quot;,sum ); printf(&quot;Sum=%d\n&quot; ,sum ); printf(&quot;Sum=%7d\n&quot;,sum); printf(&quot;Sum=%10d\n&quot;,sum); printf(&quot;Radius=%f\n&quot;, radius); printf(&quot;Radius=%10f\n&quot;, radius); printf(&quot;Radius=%15f&quot;, radius); getch(); } Output: Sum=29766 Sum=29766 Sum=  29766 Sum=  29766 Radius=3.765400 Radius=  3.765400 Radius=  3.765400
Example 6.5 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int a=2438; int b=1590; int c = 2107; printf(&quot;%10d%10d%10d\n&quot;,a,b,c); printf(&quot;%-10d %-10d %-10d \n&quot;,5*a,b*3,c*7); printf(&quot;%-10d %-10d %-10d \n&quot;,a,b,c); printf(&quot;%+d %+d %+d \n&quot;,5*a,-b*3,c*7); getch(); } Output: 2438  1590  2107 12190  4770  14749  2438  1590  2107  +12190 -4770 +14749
Example 6.6 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); float tot= 36.87; float per= 76.586588788; printf(&quot;Total Marks %f\n&quot;,tot); printf(&quot;Percentage %f\n\n&quot;,per); printf(&quot;Total Marks %.1f\n&quot;,tot); printf(&quot;Percentage %.1f\n&quot;,per); printf(&quot;Total Marks %.8f\n&quot;,tot); printf(&quot;Percentage %.8f\n&quot;,per); getch(); } Output: Total Marks 36.869999 Percentage 76.586586 Total Marks 36.9 Percentage 76.6 Total Marks 36.86999893 Percentage 76.58658600
Scanf Function scanf function is used to enter the data into computers memory through standard input device generally keyboard. It can be used to enter multiple data items by a single statement. The syntax is as follows, scanf(format_string,&var1,&var2,….,&varn) e.g.  scanf(“%d”,&x);
Scanf Function Format string Format string is a character string which contains three types of items. White space characters Non-white space characters Format specifiers
Scanf Function White space characters white space characters are those characters that are not visible on the screen. These are space, tab (\t) or new line (\n) characters. If a white space character is included in the format string it reads all consecutive white space character from the input but does not store it in a variable. Until it finds the next non white space character.
Scanf Function Non-White space characters All ASCII characters are none-white space characters, except %. If such a character is included in a format string, scanf will read the matching character from the input, but not store.
Scanf Function Format Specifiers The format specifiers are characters that direct the scanf function to read and convert characters from the input into the specific type of values. Then store them in the location given by the address of variable. A format specifier begins with a percentage sign (%) and followed a width specifier, which is followed by a conversion character, same as in printf function. The syntax of format specifier is as follows.. % [width] conversion_character
Example 6.7 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int rollno,tot; float per,marks; printf(&quot;Enter roll number &quot;); scanf(&quot;%d&quot;,&rollno); printf(&quot;Enter marks &quot;); scanf(&quot;%f&quot;,&marks); printf(&quot;Enter total marks &quot;); scanf(&quot;%d&quot;,&tot); printf(&quot;\n Your percentage is %.2f&quot;,(100.0 * marks/tot)); getch(); }
Example 6.8 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int hr,mn,sec; scanf(&quot;%d:%d:%d&quot;,&hr,&mn,&sec); printf(&quot;\n Hours  %d&quot;,hr); printf(&quot;\n Minutes %d&quot;,mn); printf(&quot;\n Seconds %d&quot;,sec); getch(); }
Example 6.9 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int x,y,a,b; scanf(&quot;%2d%3d&quot;,&x,&y); scanf(&quot;%d%d&quot;,&a,&b); printf(&quot; x = %d y = %d a = %d b = %d &quot;,x,y,a,b); getch(); }

More Related Content

What's hot (20)

concept of Array, 1D & 2D array
concept of Array, 1D & 2D arrayconcept of Array, 1D & 2D array
concept of Array, 1D & 2D array
Sangani Ankur
 
Algorithm and flowchart
Algorithm and flowchartAlgorithm and flowchart
Algorithm and flowchart
Elizabeth de Leon Aler
 
Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
Mauryasuraj98
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
amber chaudary
 
Python programming : Standard Input and Output
Python programming : Standard Input and OutputPython programming : Standard Input and Output
Python programming : Standard Input and Output
Emertxe Information Technologies Pvt Ltd
 
File handling in c
File handling in cFile handling in c
File handling in c
aakanksha s
 
Types of function call
Types of function callTypes of function call
Types of function call
ArijitDhali
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
tanmaymodi4
 
CPU INPUT OUTPUT
CPU INPUT OUTPUT CPU INPUT OUTPUT
CPU INPUT OUTPUT
Aditya Vaishampayan
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
Mayank Jain
 
Modular programming
Modular programmingModular programming
Modular programming
Mohanlal Sukhadia University (MLSU)
 
Control statements in c
Control statements in cControl statements in c
Control statements in c
Sathish Narayanan
 
Control Statement programming
Control Statement programmingControl Statement programming
Control Statement programming
University of Potsdam
 
Control structure C++
Control structure C++Control structure C++
Control structure C++
Anil Kumar
 
Constants in C Programming
Constants in C ProgrammingConstants in C Programming
Constants in C Programming
programming9
 
Structure in c
Structure in cStructure in c
Structure in c
Prabhu Govind
 
Looping statements in C
Looping statements in CLooping statements in C
Looping statements in C
Jeya Lakshmi
 
itft-Decision making and branching in java
itft-Decision making and branching in javaitft-Decision making and branching in java
itft-Decision making and branching in java
Atul Sehdev
 
Pointers in c language
Pointers in c languagePointers in c language
Pointers in c language
Tanmay Modi
 

Viewers also liked (8)

Goodbye Party For Miss Pushpa T.S - Nissim Ezekiel
Goodbye Party For Miss Pushpa T.S - Nissim  EzekielGoodbye Party For Miss Pushpa T.S - Nissim  Ezekiel
Goodbye Party For Miss Pushpa T.S - Nissim Ezekiel
Shranti Hake
 
Good Bye Party For Miss Pushpa T.
Good Bye Party For Miss Pushpa T.Good Bye Party For Miss Pushpa T.
Good Bye Party For Miss Pushpa T.
Manthan070199
 
cs submission ppt on "Goodbye party for Miss Pushpa T.S."
cs submission ppt on "Goodbye party for Miss Pushpa T.S."  cs submission ppt on "Goodbye party for Miss Pushpa T.S."
cs submission ppt on "Goodbye party for Miss Pushpa T.S."
shreya sanghvi
 
File Management
File ManagementFile Management
File Management
insanmisteri111
 
Good bye party for miss pushpa
Good  bye  party  for  miss  pushpaGood  bye  party  for  miss  pushpa
Good bye party for miss pushpa
Soham Dhameliya
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
Aakash Singh
 
Production Function
Production FunctionProduction Function
Production Function
tanveerabbott
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
elliehood
 
Goodbye Party For Miss Pushpa T.S - Nissim Ezekiel
Goodbye Party For Miss Pushpa T.S - Nissim  EzekielGoodbye Party For Miss Pushpa T.S - Nissim  Ezekiel
Goodbye Party For Miss Pushpa T.S - Nissim Ezekiel
Shranti Hake
 
Good Bye Party For Miss Pushpa T.
Good Bye Party For Miss Pushpa T.Good Bye Party For Miss Pushpa T.
Good Bye Party For Miss Pushpa T.
Manthan070199
 
cs submission ppt on "Goodbye party for Miss Pushpa T.S."
cs submission ppt on "Goodbye party for Miss Pushpa T.S."  cs submission ppt on "Goodbye party for Miss Pushpa T.S."
cs submission ppt on "Goodbye party for Miss Pushpa T.S."
shreya sanghvi
 
Good bye party for miss pushpa
Good  bye  party  for  miss  pushpaGood  bye  party  for  miss  pushpa
Good bye party for miss pushpa
Soham Dhameliya
 
Type Conversion, Precedence and Associativity
Type Conversion, Precedence and AssociativityType Conversion, Precedence and Associativity
Type Conversion, Precedence and Associativity
Aakash Singh
 
Slideshare Powerpoint presentation
Slideshare Powerpoint presentationSlideshare Powerpoint presentation
Slideshare Powerpoint presentation
elliehood
 
Ad

Similar to Input And Output (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
SowmyaJyothi3
 
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
 
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
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C Language
Adnan Khan
 
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
Thesis Scientist Private Limited
 
I o functions
I o functionsI o functions
I o functions
Dr.Sandhiya Ravi
 
C language
C languageC language
C language
TaranjeetKaur72
 
c program presentation on format specifer.pptx
c program presentation on format  specifer.pptxc program presentation on format  specifer.pptx
c program presentation on format specifer.pptx
Puskar Bhandari
 
Lecture 3
Lecture 3Lecture 3
Lecture 3
marvellous2
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
Hattori Sidek
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
arnold 7490
 
Unit2 C
Unit2 CUnit2 C
Unit2 C
arnold 7490
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
First c program
First c programFirst c program
First c program
Komal Pardeshi
 
C programming(part 3)
C programming(part 3)C programming(part 3)
C programming(part 3)
Dr. SURBHI SAROHA
 
Variable< Arithmetic Expressions and Input
Variable< Arithmetic Expressions and InputVariable< Arithmetic Expressions and Input
Variable< Arithmetic Expressions and Input
uapinturzhan
 
CHAPTER 4
CHAPTER 4CHAPTER 4
CHAPTER 4
mohd_mizan
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptx
KrishanPalSingh39
 
C SLIDES PREPARED BY M V B REDDY
C SLIDES PREPARED BY  M V B REDDYC SLIDES PREPARED BY  M V B REDDY
C SLIDES PREPARED BY M V B REDDY
Malikireddy Bramhananda Reddy
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
alish sha
 
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
SowmyaJyothi3
 
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
 
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
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C Language
Adnan Khan
 
c program presentation on format specifer.pptx
c program presentation on format  specifer.pptxc program presentation on format  specifer.pptx
c program presentation on format specifer.pptx
Puskar Bhandari
 
Ch2 introduction to c
Ch2 introduction to cCh2 introduction to c
Ch2 introduction to c
Hattori Sidek
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
Variable< Arithmetic Expressions and Input
Variable< Arithmetic Expressions and InputVariable< Arithmetic Expressions and Input
Variable< Arithmetic Expressions and Input
uapinturzhan
 
presentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptxpresentation_c_basics_1589366177_381682.pptx
presentation_c_basics_1589366177_381682.pptx
KrishanPalSingh39
 
Chap 2 input output dti2143
Chap 2  input output dti2143Chap 2  input output dti2143
Chap 2 input output dti2143
alish sha
 
Ad

More from Ghaffar Khan (20)

World is beautiful ... ...
World is beautiful ... ...World is beautiful ... ...
World is beautiful ... ...
Ghaffar Khan
 
My Presentation On Ajax
My Presentation On AjaxMy Presentation On Ajax
My Presentation On Ajax
Ghaffar Khan
 
Sorting
SortingSorting
Sorting
Ghaffar Khan
 
How A Computer Works
How A Computer WorksHow A Computer Works
How A Computer Works
Ghaffar Khan
 
For Loop
For LoopFor Loop
For Loop
Ghaffar Khan
 
Exponential and Logarthmic funtions
Exponential and Logarthmic funtionsExponential and Logarthmic funtions
Exponential and Logarthmic funtions
Ghaffar Khan
 
Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)
Ghaffar Khan
 
Functions
FunctionsFunctions
Functions
Ghaffar Khan
 
Quadratic And Polinomial Function
Quadratic And Polinomial FunctionQuadratic And Polinomial Function
Quadratic And Polinomial Function
Ghaffar Khan
 
Quadratic And Polinomial Function
 Quadratic And Polinomial Function Quadratic And Polinomial Function
Quadratic And Polinomial Function
Ghaffar Khan
 
Exponentioal And Logarthmic Functions
 Exponentioal And Logarthmic Functions Exponentioal And Logarthmic Functions
Exponentioal And Logarthmic Functions
Ghaffar Khan
 
Internet Protocol
Internet ProtocolInternet Protocol
Internet Protocol
Ghaffar Khan
 
Introduction to Computer Networks
 Introduction to Computer Networks Introduction to Computer Networks
Introduction to Computer Networks
Ghaffar Khan
 
Network Layer
Network LayerNetwork Layer
Network Layer
Ghaffar Khan
 
Control Structures
Control StructuresControl Structures
Control Structures
Ghaffar Khan
 
Surfaces
SurfacesSurfaces
Surfaces
Ghaffar Khan
 
Vector Tools
Vector ToolsVector Tools
Vector Tools
Ghaffar Khan
 
Drawing Tools
Drawing ToolsDrawing Tools
Drawing Tools
Ghaffar Khan
 
Drawing Figures
Drawing FiguresDrawing Figures
Drawing Figures
Ghaffar Khan
 
Computer Graphics Introduction
Computer Graphics IntroductionComputer Graphics Introduction
Computer Graphics Introduction
Ghaffar Khan
 
World is beautiful ... ...
World is beautiful ... ...World is beautiful ... ...
World is beautiful ... ...
Ghaffar Khan
 
My Presentation On Ajax
My Presentation On AjaxMy Presentation On Ajax
My Presentation On Ajax
Ghaffar Khan
 
How A Computer Works
How A Computer WorksHow A Computer Works
How A Computer Works
Ghaffar Khan
 
Exponential and Logarthmic funtions
Exponential and Logarthmic funtionsExponential and Logarthmic funtions
Exponential and Logarthmic funtions
Ghaffar Khan
 
Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)Exponential and Logarthmic funtions (1)
Exponential and Logarthmic funtions (1)
Ghaffar Khan
 
Quadratic And Polinomial Function
Quadratic And Polinomial FunctionQuadratic And Polinomial Function
Quadratic And Polinomial Function
Ghaffar Khan
 
Quadratic And Polinomial Function
 Quadratic And Polinomial Function Quadratic And Polinomial Function
Quadratic And Polinomial Function
Ghaffar Khan
 
Exponentioal And Logarthmic Functions
 Exponentioal And Logarthmic Functions Exponentioal And Logarthmic Functions
Exponentioal And Logarthmic Functions
Ghaffar Khan
 
Introduction to Computer Networks
 Introduction to Computer Networks Introduction to Computer Networks
Introduction to Computer Networks
Ghaffar Khan
 
Control Structures
Control StructuresControl Structures
Control Structures
Ghaffar Khan
 
Computer Graphics Introduction
Computer Graphics IntroductionComputer Graphics Introduction
Computer Graphics Introduction
Ghaffar Khan
 

Recently uploaded (20)

ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 
Maxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing placeMaxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing place
usersalmanrazdelhi
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptxECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
ECS25 - The adventures of a Microsoft 365 Platform Owner - Website.pptx
Jasper Oosterveld
 
Measuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI SuccessMeasuring Microsoft 365 Copilot and Gen AI Success
Measuring Microsoft 365 Copilot and Gen AI Success
Nikki Chapple
 
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 ADr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr Jimmy Schwarzkopf presentation on the SUMMIT 2025 A
Dr. Jimmy Schwarzkopf
 
Dev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API WorkflowsDev Dives: System-to-system integration with UiPath API Workflows
Dev Dives: System-to-system integration with UiPath API Workflows
UiPathCommunity
 
UiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build PipelinesUiPath Community Zurich: Release Management and Build Pipelines
UiPath Community Zurich: Release Management and Build Pipelines
UiPathCommunity
 
Improving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevExImproving Developer Productivity With DORA, SPACE, and DevEx
Improving Developer Productivity With DORA, SPACE, and DevEx
Justin Reock
 
Droidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing HealthcareDroidal: AI Agents Revolutionizing Healthcare
Droidal: AI Agents Revolutionizing Healthcare
Droidal LLC
 
TrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy ContractingTrustArc Webinar: Mastering Privacy Contracting
TrustArc Webinar: Mastering Privacy Contracting
TrustArc
 
Securiport - A Border Security Company
Securiport  -  A Border Security CompanySecuriport  -  A Border Security Company
Securiport - A Border Security Company
Securiport
 
Microsoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentationMicrosoft Build 2025 takeaways in one presentation
Microsoft Build 2025 takeaways in one presentation
Digitalmara
 
STKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 versionSTKI Israel Market Study 2025 final v1 version
STKI Israel Market Study 2025 final v1 version
Dr. Jimmy Schwarzkopf
 
Maxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing placeMaxx nft market place new generation nft marketing place
Maxx nft market place new generation nft marketing place
usersalmanrazdelhi
 
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyesEnd-to-end Assurance for SD-WAN & SASE with ThousandEyes
End-to-end Assurance for SD-WAN & SASE with ThousandEyes
ThousandEyes
 
6th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 20256th Power Grid Model Meetup - 21 May 2025
6th Power Grid Model Meetup - 21 May 2025
DanBrown980551
 
Data Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any ApplicationData Virtualization: Bringing the Power of FME to Any Application
Data Virtualization: Bringing the Power of FME to Any Application
Safe Software
 
European Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility TestingEuropean Accessibility Act & Integrated Accessibility Testing
European Accessibility Act & Integrated Accessibility Testing
Julia Undeutsch
 
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk TechniciansOffshore IT Support: Balancing In-House and Offshore Help Desk Technicians
Offshore IT Support: Balancing In-House and Offshore Help Desk Technicians
john823664
 
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AI Emotional Actors:  “When Machines Learn to Feel and Perform"AI Emotional Actors:  “When Machines Learn to Feel and Perform"
AI Emotional Actors: “When Machines Learn to Feel and Perform"
AkashKumar809858
 
AI Trends - Mary Meeker
AI Trends - Mary MeekerAI Trends - Mary Meeker
AI Trends - Mary Meeker
Razin Mustafiz
 
Grannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI ExperiencesGrannie’s Journey to Using Healthcare AI Experiences
Grannie’s Journey to Using Healthcare AI Experiences
Lauren Parr
 

Input And Output

  • 1. Input and Output A Lecture by Abdul ghaffar Khan Chapter #. 6
  • 2. Input and Output Input: Input is a process of entering the data ito the computer’s memory Output: Output is a process of translating data that are in machine-readable form into a form understandable by humans or readable by other machines.
  • 3. I/O Functions Character I/O getchar() & putchar() Formatted I/O printf() and scanf() String I/O gets() and puts() Note : To use any of these function first include the appropriate header file in your program.
  • 4. Character I/O getchar() function getchar() function is used to enter a single character through the standard input device generally keyboard . The syntax of the function is variable = getchar()
  • 5. Character I/O putchar() function putchar() function displays a character on the screen. This function takes a character as an argument.The syntax of the function is putchar( variable )
  • 6. Character I/O Example 6.1 #include <stdio.h> #include <ctype.h> void main ( void ) { char grade; printf(“Type a character? “); grade = getchar(); grade=toupper(grade); printf(“Your grade is “); putchar(grade); }
  • 7. Formatted I/O Formatted I/O means to control the type, width, precision and other attribute of the data during input and output process. Two functions are mostly used in C language for this purpose are printf() scanf()
  • 8. Formatted I/O Printf Function: printf is function used to output any type of data either characters, strings, numbers etc.. The syntax of printf function is printf(format_string, var1, var2,….varn);
  • 9. Printf Function Format string The format string is a character string that may contain two types of elements Plain text Any plain text included in the format string displayed on the screen as it is except Escape Sequence Characters and Format Specifiers. Format Specifiers. Format Specifiers are instructions to the function to display a data in a specific format. (continue….)
  • 10. Printf Function The syntax of one format specifier is as follows % [flag] [width] [.prec] conversion_char in a format string there may be any number of format specifiers. Flags (optional) - , left justifies the result + , always puts a sign before a number depending on the number blank , positive value will have a space before it and negative number will have a minus sign before the number. Width (optional) This is an integer value which specifies the minimum width of the data. (continue..)
  • 11. Printf Function Precision (optional) Is an integer number to specify the number of decimal places to be displayed in the output for a floating point number. Conversion character (format specifier) There are as many conversion characters as the standard data types are in the ‘C’ language some of those are listed below d sign decimal integer u unsigned decimal integer id long f floating point e floating with exponent o octal integer x hexadecimal c single character s string (multiple characters) (continue…)
  • 12. Printf Function Variable list The second argument of the function is a list of variables. Here variables , values and expressions can be used to supply the value to the function too display. Example 6.2: int x=34; float y=45.34; char c =‘F’; char s[] = “this is a string”; Printf(“ Output is %d \t %c \t %f \t %s \n”,x,c,y,s); Output is 34 F 45.340000 this is a string
  • 13. Example 6.3 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int roll_no = 450, marks=760; float per,total= 900.0; char section = 'B'; per = (marks / total) *100.0; printf(&quot;Rol1 Number %d\n&quot;,roll_no); printf(&quot;Section %c\n&quot;,section); printf(&quot;You Secure %d marks out of %f marks\n&quot;, marks, total); printf (&quot;Percentage %f\n&quot;,per); getch(); } Output: Rol1 Number 450 Section B You Secure 760 marks out of 900 marks Percentage 84.444443
  • 14. Example 6.4 #include <stdio.h> #include <conio.h> void main(void) { int sum = 29766; float radius = 3.7654; clrscr(); printf(&quot;Sum=%2d\n&quot;,sum ); printf(&quot;Sum=%d\n&quot; ,sum ); printf(&quot;Sum=%7d\n&quot;,sum); printf(&quot;Sum=%10d\n&quot;,sum); printf(&quot;Radius=%f\n&quot;, radius); printf(&quot;Radius=%10f\n&quot;, radius); printf(&quot;Radius=%15f&quot;, radius); getch(); } Output: Sum=29766 Sum=29766 Sum= 29766 Sum= 29766 Radius=3.765400 Radius= 3.765400 Radius= 3.765400
  • 15. Example 6.5 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int a=2438; int b=1590; int c = 2107; printf(&quot;%10d%10d%10d\n&quot;,a,b,c); printf(&quot;%-10d %-10d %-10d \n&quot;,5*a,b*3,c*7); printf(&quot;%-10d %-10d %-10d \n&quot;,a,b,c); printf(&quot;%+d %+d %+d \n&quot;,5*a,-b*3,c*7); getch(); } Output: 2438 1590 2107 12190 4770 14749 2438 1590 2107 +12190 -4770 +14749
  • 16. Example 6.6 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); float tot= 36.87; float per= 76.586588788; printf(&quot;Total Marks %f\n&quot;,tot); printf(&quot;Percentage %f\n\n&quot;,per); printf(&quot;Total Marks %.1f\n&quot;,tot); printf(&quot;Percentage %.1f\n&quot;,per); printf(&quot;Total Marks %.8f\n&quot;,tot); printf(&quot;Percentage %.8f\n&quot;,per); getch(); } Output: Total Marks 36.869999 Percentage 76.586586 Total Marks 36.9 Percentage 76.6 Total Marks 36.86999893 Percentage 76.58658600
  • 17. Scanf Function scanf function is used to enter the data into computers memory through standard input device generally keyboard. It can be used to enter multiple data items by a single statement. The syntax is as follows, scanf(format_string,&var1,&var2,….,&varn) e.g. scanf(“%d”,&x);
  • 18. Scanf Function Format string Format string is a character string which contains three types of items. White space characters Non-white space characters Format specifiers
  • 19. Scanf Function White space characters white space characters are those characters that are not visible on the screen. These are space, tab (\t) or new line (\n) characters. If a white space character is included in the format string it reads all consecutive white space character from the input but does not store it in a variable. Until it finds the next non white space character.
  • 20. Scanf Function Non-White space characters All ASCII characters are none-white space characters, except %. If such a character is included in a format string, scanf will read the matching character from the input, but not store.
  • 21. Scanf Function Format Specifiers The format specifiers are characters that direct the scanf function to read and convert characters from the input into the specific type of values. Then store them in the location given by the address of variable. A format specifier begins with a percentage sign (%) and followed a width specifier, which is followed by a conversion character, same as in printf function. The syntax of format specifier is as follows.. % [width] conversion_character
  • 22. Example 6.7 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int rollno,tot; float per,marks; printf(&quot;Enter roll number &quot;); scanf(&quot;%d&quot;,&rollno); printf(&quot;Enter marks &quot;); scanf(&quot;%f&quot;,&marks); printf(&quot;Enter total marks &quot;); scanf(&quot;%d&quot;,&tot); printf(&quot;\n Your percentage is %.2f&quot;,(100.0 * marks/tot)); getch(); }
  • 23. Example 6.8 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int hr,mn,sec; scanf(&quot;%d:%d:%d&quot;,&hr,&mn,&sec); printf(&quot;\n Hours %d&quot;,hr); printf(&quot;\n Minutes %d&quot;,mn); printf(&quot;\n Seconds %d&quot;,sec); getch(); }
  • 24. Example 6.9 #include <stdio.h> #include <conio.h> void main (void) { clrscr(); int x,y,a,b; scanf(&quot;%2d%3d&quot;,&x,&y); scanf(&quot;%d%d&quot;,&a,&b); printf(&quot; x = %d y = %d a = %d b = %d &quot;,x,y,a,b); getch(); }