SlideShare a Scribd company logo
1 of 15
Programming Fundamentals
Week 2A
CS-102
Contents
• Input and Output
• Flow Chart
• Output as printf() function
• Example
• Reading from Keyboard using scanf()
• Example
• IDE and Online code checking
Input and Output to a Program/System
In C Programming inside Computer
• Input to a program can be scanned from a keyboard in C
• Output of a C program is taken to the Black screen, Called console
• Enter key( ) is recognized as input completion/terminator (but not always)
In password scanning command, each alphanumeric character (A-z, 0-9, special
characters, etc.) is scanned directly and * is pasted on the console, so it’s a two way
process
C Programming for an Embedded system / controller
• Sometimes Input is read from an electronic port, a button or a switch which uses
a check status function
• Output can also be given to a port, a relay or a socket to run some appliances or
convey messages
Standard Input and Output Library
• The standard I/O Library is stdio.h
Input/output in Flowchart
It represents the requirements of a program or displays certain data
• Represented by parallelograms
• indicate an input or output operation
Display message
“How many
hours did you
work?”
Read Hours
Printing something on console
printf function is used for printing something on console.
The % sign, also known as format specifier, when used inside a double
quoted string, the variable will appear on this position.
Consequently, %c means that a character will appear here;
For example: displaying a character A should be done as follow.
Format Specifiers
If you want to display a % Sign
• You write %% inside a string
Example Program
Reading from Keyboard
• scanf function, that is the member of
stdio.h, is used for reading input from
a keyboard in C Programming
• For scanning, we use a & sign with
the variable, that is to be taken from
user
• For printing, only variable name is
used.
#include <stdio.h>
int main()
{
int x;
scanf("%d", &x);
printf("%d", x);
return 0;
}
Rules for scanf
• All rules for format specifier are same
• The only difference is that it require input and thus the program waits
for the user to input something.
• A wrong entry causes error which is given by debugger
Example
#include <stdio.h>
int main()
{
int x;
scanf("%d", &x);
printf("%d", x);
return 0;
}
Things to remember about printf and scanf
• printf() is used to display the output
• scanf() is used to read the inputs.
• printf() and scanf() functions are declared in “stdio.h” header file in C
library.
• All syntax in C language including printf() and scanf() functions are
case sensitive.
About IDE
• Dev C++ is used which is available in Teams
• Online: https://www.onlinegdb.com/online_c_compiler
Thanks

More Related Content

What's hot

What's hot (20)

Input output statement in C
Input output statement in CInput output statement in C
Input output statement in C
 
Basic Input and Output
Basic Input and OutputBasic Input and Output
Basic Input and Output
 
keyword
keywordkeyword
keyword
 
CP Handout#2
CP Handout#2CP Handout#2
CP Handout#2
 
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
 
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 C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Learning the C Language
Learning the C LanguageLearning the C Language
Learning the C Language
 
7. input and output functions
7. input and output functions7. input and output functions
7. input and output functions
 
First c program
First c programFirst c program
First c program
 
CP Handout#8
CP Handout#8CP Handout#8
CP Handout#8
 
L03vars
L03varsL03vars
L03vars
 
MATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output CommandsMATLAB programming tips 2 - Input and Output Commands
MATLAB programming tips 2 - Input and Output Commands
 
CP Handout#4
CP Handout#4CP Handout#4
CP Handout#4
 
Complete C programming Language Course
Complete C programming Language CourseComplete C programming Language Course
Complete C programming Language Course
 
C Token’s
C Token’sC Token’s
C Token’s
 
CP Handout#3
CP Handout#3CP Handout#3
CP Handout#3
 
C programming
C programming C programming
C programming
 
CP Handout#5
CP Handout#5CP Handout#5
CP Handout#5
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 

Similar to 2.1 input and output in c

Fundamental of C Programming Language and Basic Input/Output Function
  Fundamental of C Programming Language and Basic Input/Output Function  Fundamental of C Programming Language and Basic Input/Output Function
Fundamental of C Programming Language and Basic Input/Output Functionimtiazalijoono
 
Cse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingCse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingMd. Ashikur Rahman
 
3. input output instruction in c programming by digital wave
3. input output instruction in c programming by digital wave3. input output instruction in c programming by digital wave
3. input output instruction in c programming by digital waveRahulSharma4566
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C LanguageAdnan Khan
 
Chapter3
Chapter3Chapter3
Chapter3Kamran
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)indrasir
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5REHAN IJAZ
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecturemyinstalab
 
Input output in c
Input output in cInput output in c
Input output in cDucat
 
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
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentalsJawad Khan
 
Assembly Language Programming
Assembly Language ProgrammingAssembly Language Programming
Assembly Language ProgrammingNiropam Das
 
C programming language for beginners
C programming language for beginners C programming language for beginners
C programming language for beginners ShreyaSingh291866
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptxRohitRaj744272
 

Similar to 2.1 input and output in c (20)

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
 
Building Simple C Program
Building Simple  C ProgramBuilding Simple  C Program
Building Simple C Program
 
Cse115 lecture04introtoc programming
Cse115 lecture04introtoc programmingCse115 lecture04introtoc programming
Cse115 lecture04introtoc programming
 
3. input output instruction in c programming by digital wave
3. input output instruction in c programming by digital wave3. input output instruction in c programming by digital wave
3. input output instruction in c programming by digital wave
 
Input and Output In C Language
Input and Output In C LanguageInput and Output In C Language
Input and Output In C Language
 
UNIT-II CP DOC.docx
UNIT-II CP DOC.docxUNIT-II CP DOC.docx
UNIT-II CP DOC.docx
 
Chapter3
Chapter3Chapter3
Chapter3
 
C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)C basics 4 std11(GujBoard)
C basics 4 std11(GujBoard)
 
Programming Fundamentals lecture 5
Programming Fundamentals lecture 5Programming Fundamentals lecture 5
Programming Fundamentals lecture 5
 
C Language Programming Introduction Lecture
C Language Programming Introduction LectureC Language Programming Introduction Lecture
C Language Programming Introduction Lecture
 
Input output in c
Input output in cInput output in c
Input output in c
 
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
 
1.1 programming fundamentals
1.1 programming fundamentals1.1 programming fundamentals
1.1 programming fundamentals
 
Unit-IV.pptx
Unit-IV.pptxUnit-IV.pptx
Unit-IV.pptx
 
Cpu
CpuCpu
Cpu
 
Chapter1.pptx
Chapter1.pptxChapter1.pptx
Chapter1.pptx
 
C++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWAREC++ AND CATEGORIES OF SOFTWARE
C++ AND CATEGORIES OF SOFTWARE
 
Assembly Language Programming
Assembly Language ProgrammingAssembly Language Programming
Assembly Language Programming
 
C programming language for beginners
C programming language for beginners C programming language for beginners
C programming language for beginners
 
c_pro_introduction.pptx
c_pro_introduction.pptxc_pro_introduction.pptx
c_pro_introduction.pptx
 

More from Jawad Khan

2.2 variable arithmetics and logics
2.2 variable arithmetics and logics2.2 variable arithmetics and logics
2.2 variable arithmetics and logicsJawad Khan
 
7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instrumentsJawad Khan
 
6. emi instrument transformers (with marking)
6. emi   instrument transformers (with marking)6. emi   instrument transformers (with marking)
6. emi instrument transformers (with marking)Jawad Khan
 
5 emi ac bridges (with marking)
5 emi  ac bridges (with marking)5 emi  ac bridges (with marking)
5 emi ac bridges (with marking)Jawad Khan
 
4. emi potentiometer and ac bridges
4. emi  potentiometer and ac bridges4. emi  potentiometer and ac bridges
4. emi potentiometer and ac bridgesJawad Khan
 
3 .emi wattmeter and energy meter
3 .emi   wattmeter and energy meter3 .emi   wattmeter and energy meter
3 .emi wattmeter and energy meterJawad Khan
 
2. emi analog electromechanical instruments
2. emi  analog electromechanical instruments2. emi  analog electromechanical instruments
2. emi analog electromechanical instrumentsJawad Khan
 
1. emi concept of measurement system
1. emi   concept of measurement system1. emi   concept of measurement system
1. emi concept of measurement systemJawad Khan
 
Varibale frequency response lecturer 2 - audio+
Varibale frequency response   lecturer 2 - audio+Varibale frequency response   lecturer 2 - audio+
Varibale frequency response lecturer 2 - audio+Jawad Khan
 
Variable frequency response lecture 3 - audio
Variable frequency response   lecture 3 - audioVariable frequency response   lecture 3 - audio
Variable frequency response lecture 3 - audioJawad Khan
 
Varibale frequency response lecturer 1 - audio
Varibale frequency response   lecturer 1 - audioVaribale frequency response   lecturer 1 - audio
Varibale frequency response lecturer 1 - audioJawad Khan
 
Two port network - part 3
Two port network - part 3Two port network - part 3
Two port network - part 3Jawad Khan
 
Two port network - part 2
Two port network - part 2Two port network - part 2
Two port network - part 2Jawad Khan
 
Two port network - part 1
Two port network - part 1Two port network - part 1
Two port network - part 1Jawad Khan
 
4. ideal transformer and load conversion
4. ideal transformer and load conversion4. ideal transformer and load conversion
4. ideal transformer and load conversionJawad Khan
 
3. magnetic coupled circuits examples
3. magnetic coupled circuits examples3. magnetic coupled circuits examples
3. magnetic coupled circuits examplesJawad Khan
 
2. magnetic coupled circuits
2. magnetic coupled circuits2. magnetic coupled circuits
2. magnetic coupled circuitsJawad Khan
 
1. magnetic coupled circuits
1. magnetic coupled circuits1. magnetic coupled circuits
1. magnetic coupled circuitsJawad Khan
 
introduction to circuit analysis and review of basic
introduction to circuit analysis and review of basicintroduction to circuit analysis and review of basic
introduction to circuit analysis and review of basicJawad Khan
 
Active Filters - Electrical Network Analysis
Active Filters - Electrical Network AnalysisActive Filters - Electrical Network Analysis
Active Filters - Electrical Network AnalysisJawad Khan
 

More from Jawad Khan (20)

2.2 variable arithmetics and logics
2.2 variable arithmetics and logics2.2 variable arithmetics and logics
2.2 variable arithmetics and logics
 
7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments7 8. emi - analog instruments and digital instruments
7 8. emi - analog instruments and digital instruments
 
6. emi instrument transformers (with marking)
6. emi   instrument transformers (with marking)6. emi   instrument transformers (with marking)
6. emi instrument transformers (with marking)
 
5 emi ac bridges (with marking)
5 emi  ac bridges (with marking)5 emi  ac bridges (with marking)
5 emi ac bridges (with marking)
 
4. emi potentiometer and ac bridges
4. emi  potentiometer and ac bridges4. emi  potentiometer and ac bridges
4. emi potentiometer and ac bridges
 
3 .emi wattmeter and energy meter
3 .emi   wattmeter and energy meter3 .emi   wattmeter and energy meter
3 .emi wattmeter and energy meter
 
2. emi analog electromechanical instruments
2. emi  analog electromechanical instruments2. emi  analog electromechanical instruments
2. emi analog electromechanical instruments
 
1. emi concept of measurement system
1. emi   concept of measurement system1. emi   concept of measurement system
1. emi concept of measurement system
 
Varibale frequency response lecturer 2 - audio+
Varibale frequency response   lecturer 2 - audio+Varibale frequency response   lecturer 2 - audio+
Varibale frequency response lecturer 2 - audio+
 
Variable frequency response lecture 3 - audio
Variable frequency response   lecture 3 - audioVariable frequency response   lecture 3 - audio
Variable frequency response lecture 3 - audio
 
Varibale frequency response lecturer 1 - audio
Varibale frequency response   lecturer 1 - audioVaribale frequency response   lecturer 1 - audio
Varibale frequency response lecturer 1 - audio
 
Two port network - part 3
Two port network - part 3Two port network - part 3
Two port network - part 3
 
Two port network - part 2
Two port network - part 2Two port network - part 2
Two port network - part 2
 
Two port network - part 1
Two port network - part 1Two port network - part 1
Two port network - part 1
 
4. ideal transformer and load conversion
4. ideal transformer and load conversion4. ideal transformer and load conversion
4. ideal transformer and load conversion
 
3. magnetic coupled circuits examples
3. magnetic coupled circuits examples3. magnetic coupled circuits examples
3. magnetic coupled circuits examples
 
2. magnetic coupled circuits
2. magnetic coupled circuits2. magnetic coupled circuits
2. magnetic coupled circuits
 
1. magnetic coupled circuits
1. magnetic coupled circuits1. magnetic coupled circuits
1. magnetic coupled circuits
 
introduction to circuit analysis and review of basic
introduction to circuit analysis and review of basicintroduction to circuit analysis and review of basic
introduction to circuit analysis and review of basic
 
Active Filters - Electrical Network Analysis
Active Filters - Electrical Network AnalysisActive Filters - Electrical Network Analysis
Active Filters - Electrical Network Analysis
 

Recently uploaded

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 ImpactPECB
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...RKavithamani
 
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 ModeThiyagu K
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
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.pptxheathfieldcps1
 
“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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
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
 

Recently uploaded (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
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
Privatization and Disinvestment - Meaning, Objectives, Advantages and Disadva...
 
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
 
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
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
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
 
“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...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
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
 

2.1 input and output in c

  • 2. Contents • Input and Output • Flow Chart • Output as printf() function • Example • Reading from Keyboard using scanf() • Example • IDE and Online code checking
  • 3. Input and Output to a Program/System In C Programming inside Computer • Input to a program can be scanned from a keyboard in C • Output of a C program is taken to the Black screen, Called console • Enter key( ) is recognized as input completion/terminator (but not always) In password scanning command, each alphanumeric character (A-z, 0-9, special characters, etc.) is scanned directly and * is pasted on the console, so it’s a two way process C Programming for an Embedded system / controller • Sometimes Input is read from an electronic port, a button or a switch which uses a check status function • Output can also be given to a port, a relay or a socket to run some appliances or convey messages
  • 4. Standard Input and Output Library • The standard I/O Library is stdio.h
  • 5. Input/output in Flowchart It represents the requirements of a program or displays certain data • Represented by parallelograms • indicate an input or output operation Display message “How many hours did you work?” Read Hours
  • 6. Printing something on console printf function is used for printing something on console. The % sign, also known as format specifier, when used inside a double quoted string, the variable will appear on this position. Consequently, %c means that a character will appear here; For example: displaying a character A should be done as follow.
  • 8. If you want to display a % Sign • You write %% inside a string
  • 10. Reading from Keyboard • scanf function, that is the member of stdio.h, is used for reading input from a keyboard in C Programming • For scanning, we use a & sign with the variable, that is to be taken from user • For printing, only variable name is used. #include <stdio.h> int main() { int x; scanf("%d", &x); printf("%d", x); return 0; }
  • 11. Rules for scanf • All rules for format specifier are same • The only difference is that it require input and thus the program waits for the user to input something. • A wrong entry causes error which is given by debugger
  • 12. Example #include <stdio.h> int main() { int x; scanf("%d", &x); printf("%d", x); return 0; }
  • 13. Things to remember about printf and scanf • printf() is used to display the output • scanf() is used to read the inputs. • printf() and scanf() functions are declared in “stdio.h” header file in C library. • All syntax in C language including printf() and scanf() functions are case sensitive.
  • 14. About IDE • Dev C++ is used which is available in Teams • Online: https://www.onlinegdb.com/online_c_compiler