SlideShare a Scribd company logo
1 of 40
Dinesh Maharjan, 2022
Programming in C
Input Output
Instructor: Dinesh Maharjan
2022
#include<stdio.h>
void main(){
printf("Name:tt "Dinesh"");
printf("nMobile No:tt 9841429635");
printf("nSection: tt D");
printf("a");
printf("n");
printf("HellorNepal");
}
Escape Sequence
Place Holder Data Type Displayed
%i , %d int, long, short, char,
unsigned int
Decimal Value, ASCII
value
%u Unsigned int Decimal Value
%o Int Octal Value
%x, %X Int Hexadecimal
%f Float Float value with zeros
%g %G Float, Double Float value with no zeros
%e, %E Float, Double Float in exponent
%lf Double Double value
%c Char Single character
%s Array of Character String
#include<stdio.h>
void main(){
printf("Decimal No =%5d",123);
printf("nOctal No =%5o",123);
printf("nHex No =%5x",123);
printf("nFloat with g =%5g",123.456);
printf("nFloat with f =%5f",123.4560);
printf("nFloat with f =%5.1f",123.4560);
printf("nFloat with lf =%5lf",123.456);
printf("nFloat with e =%5e",123.456);
printf("nSingle Char = %5c",'A');
printf("nString %5s","Hello");
}
printf
Decimal No = 123
Octal No = 173
Hex No = 7b
Float with g =123.456
Float with f =123.456000
Float with f =123.5
Float with lf =123.456000
Float with e =1.234560e+002
Single Char = A
String Hello
#include<stdio.h>
void main(){
int a=45;
int *ptr=&a;
unsigned int b=56;
printf("Address of a in decimal =%dn",&a);
printf("Address of a in hexadecimal =%xn",&a);
printf("Content of pointer =%p",ptr);
printf("Decimal No =%d",b);
}
Address of Variable
• Single character
• #include<stdio.h>
• void main(){
• char ch;
• ch=getchar();
• putchar(ch);
• }
getchar(), putchar()
• When we use %s for scanf,
it only scans string before
white space
• White spcace can be space,
tab or new line
scanf() for string
#include<stdio.h>
void main(){
char sen[50];
scanf(“%s”,sen);
printf(sen);
}
scanf() for string
#include<stdio.h>
void main(){
char sen[50];
scanf(“%[^n]”,sen);
printf(sen);
}
• Reads data even after
white space also
getc() and putc()
#include<stdio.h>
void main(){
char ch;
ch=getc(stdin);
putc(ch,stdout);
}
• Reads single
character from
specified source
• Write single
character to specified
resource
getch()
#include<stdio.h>
void main(){
char ch;
ch=getch();
putchar(ch);
}
• Non standard function
• Not part standard C
• Defined in conio.h
• getch() reads a single
character without enter
• It does not echo the
input character.
getche()
#include<stdio.h>
void main(){
char ch;
ch=getche();
putchar(ch);
}
• Non standard function
• Not part standard C
• Defined in conio.h
• getche() reads a single
character without enter
• It echos the input
character.
gets() and puts()
#include<stdio.h>
void main(){
char sen[50];
gets(sen);
puts(sen);
}
• gets() can read
sentence.
• puts() can write
sentence.
Symbolic Constant
#include<stdio.h>
#define PI 3.14
void main(){
double r,area,peri;
puts("Enter the radius");
scanf("%lf",&r);
area=PI*r*r;
peri=2*PI*r;
printf("Area =%.2f",area);
printf("nPerimeter=%.2f",peri);
}

More Related Content

Similar to Unit 3 Input Output.pptx

Similar to Unit 3 Input Output.pptx (20)

All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
 
C basics
C basicsC basics
C basics
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
String
StringString
String
 
C Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossainC Programming Exam problems & Solution by sazzad hossain
C Programming Exam problems & Solution by sazzad hossain
 
Input output functions
Input output functionsInput output functions
Input output functions
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
 
Arrays
ArraysArrays
Arrays
 
string , pointer
string , pointerstring , pointer
string , pointer
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
 
C language concept with code apna college.pdf
C language concept with code apna college.pdfC language concept with code apna college.pdf
C language concept with code apna college.pdf
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
 
Najmul
Najmul  Najmul
Najmul
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐาน
 
input
inputinput
input
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
 
SaraPIC
SaraPICSaraPIC
SaraPIC
 
C Programming
C ProgrammingC Programming
C Programming
 

More from Precise Mya

Unit 7 Functions.pptx
Unit 7 Functions.pptxUnit 7 Functions.pptx
Unit 7 Functions.pptxPrecise Mya
 
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptxUnit 2 Elements of C.pptx
Unit 2 Elements of C.pptxPrecise Mya
 
Unit 1 Problem Solving.pptx
Unit 1 Problem Solving.pptxUnit 1 Problem Solving.pptx
Unit 1 Problem Solving.pptxPrecise Mya
 
Unit 6 Arrays.pptx
Unit 6 Arrays.pptxUnit 6 Arrays.pptx
Unit 6 Arrays.pptxPrecise Mya
 
Unit 5 Control Structures.pptx
Unit 5 Control Structures.pptxUnit 5 Control Structures.pptx
Unit 5 Control Structures.pptxPrecise Mya
 
Unit 2 Communication System.pptx
Unit 2 Communication System.pptxUnit 2 Communication System.pptx
Unit 2 Communication System.pptxPrecise Mya
 

More from Precise Mya (6)

Unit 7 Functions.pptx
Unit 7 Functions.pptxUnit 7 Functions.pptx
Unit 7 Functions.pptx
 
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptxUnit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
 
Unit 1 Problem Solving.pptx
Unit 1 Problem Solving.pptxUnit 1 Problem Solving.pptx
Unit 1 Problem Solving.pptx
 
Unit 6 Arrays.pptx
Unit 6 Arrays.pptxUnit 6 Arrays.pptx
Unit 6 Arrays.pptx
 
Unit 5 Control Structures.pptx
Unit 5 Control Structures.pptxUnit 5 Control Structures.pptx
Unit 5 Control Structures.pptx
 
Unit 2 Communication System.pptx
Unit 2 Communication System.pptxUnit 2 Communication System.pptx
Unit 2 Communication System.pptx
 

Recently uploaded

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
 
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
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
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
 
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
 
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
 
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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
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
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 

Recently uploaded (20)

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...
 
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
 
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
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
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
 
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...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
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
 
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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
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
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 

Unit 3 Input Output.pptx

  • 1. Dinesh Maharjan, 2022 Programming in C Input Output Instructor: Dinesh Maharjan 2022
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. #include<stdio.h> void main(){ printf("Name:tt "Dinesh""); printf("nMobile No:tt 9841429635"); printf("nSection: tt D"); printf("a"); printf("n"); printf("HellorNepal"); } Escape Sequence
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16. Place Holder Data Type Displayed %i , %d int, long, short, char, unsigned int Decimal Value, ASCII value %u Unsigned int Decimal Value %o Int Octal Value %x, %X Int Hexadecimal %f Float Float value with zeros %g %G Float, Double Float value with no zeros %e, %E Float, Double Float in exponent %lf Double Double value %c Char Single character %s Array of Character String
  • 17. #include<stdio.h> void main(){ printf("Decimal No =%5d",123); printf("nOctal No =%5o",123); printf("nHex No =%5x",123); printf("nFloat with g =%5g",123.456); printf("nFloat with f =%5f",123.4560); printf("nFloat with f =%5.1f",123.4560); printf("nFloat with lf =%5lf",123.456); printf("nFloat with e =%5e",123.456); printf("nSingle Char = %5c",'A'); printf("nString %5s","Hello"); } printf Decimal No = 123 Octal No = 173 Hex No = 7b Float with g =123.456 Float with f =123.456000 Float with f =123.5 Float with lf =123.456000 Float with e =1.234560e+002 Single Char = A String Hello
  • 18. #include<stdio.h> void main(){ int a=45; int *ptr=&a; unsigned int b=56; printf("Address of a in decimal =%dn",&a); printf("Address of a in hexadecimal =%xn",&a); printf("Content of pointer =%p",ptr); printf("Decimal No =%d",b); } Address of Variable
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29. • Single character • #include<stdio.h> • void main(){ • char ch; • ch=getchar(); • putchar(ch); • } getchar(), putchar()
  • 30. • When we use %s for scanf, it only scans string before white space • White spcace can be space, tab or new line scanf() for string #include<stdio.h> void main(){ char sen[50]; scanf(“%s”,sen); printf(sen); }
  • 31. scanf() for string #include<stdio.h> void main(){ char sen[50]; scanf(“%[^n]”,sen); printf(sen); } • Reads data even after white space also
  • 32. getc() and putc() #include<stdio.h> void main(){ char ch; ch=getc(stdin); putc(ch,stdout); } • Reads single character from specified source • Write single character to specified resource
  • 33. getch() #include<stdio.h> void main(){ char ch; ch=getch(); putchar(ch); } • Non standard function • Not part standard C • Defined in conio.h • getch() reads a single character without enter • It does not echo the input character.
  • 34. getche() #include<stdio.h> void main(){ char ch; ch=getche(); putchar(ch); } • Non standard function • Not part standard C • Defined in conio.h • getche() reads a single character without enter • It echos the input character.
  • 35. gets() and puts() #include<stdio.h> void main(){ char sen[50]; gets(sen); puts(sen); } • gets() can read sentence. • puts() can write sentence.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40. Symbolic Constant #include<stdio.h> #define PI 3.14 void main(){ double r,area,peri; puts("Enter the radius"); scanf("%lf",&r); area=PI*r*r; peri=2*PI*r; printf("Area =%.2f",area); printf("nPerimeter=%.2f",peri); }

Editor's Notes

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40