SlideShare a Scribd company logo
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

All important c programby makhan kumbhkar
All important c programby makhan kumbhkarAll important c programby makhan kumbhkar
All important c programby makhan kumbhkar
sandeep kumbhkar
 
4. chapter iii
4. chapter iii4. chapter iii
4. chapter iii
Chhom Karath
 
C basics
C basicsC basics
C basicsMSc CST
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
Abhishek Sinha
 
C Programming lab
C Programming labC Programming lab
C Programming lab
Vikram Nandini
 
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
Sazzad Hossain, ITP, MBA, CSCA™
 
Input output functions
Input output functionsInput output functions
Input output functionshyderali123
 
Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Arrays
ArraysArrays
string , pointer
string , pointerstring , pointer
string , pointer
Arafat Bin Reza
 
Unit 5 Foc
Unit 5 FocUnit 5 Foc
Unit 5 Foc
JAYA
 
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
mhande899
 
9.C Programming
9.C Programming9.C Programming
9.C Programming
Export Promotion Bureau
 
Najmul
Najmul  Najmul
Najmul
Najmul Ashik
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐานKrunee Thitthamon
 
input
inputinput
input
teach4uin
 
Best C Programming Solution
Best C Programming SolutionBest C Programming Solution
Best C Programming Solution
yogini sharma
 
C Programming
C ProgrammingC Programming
C Programming
Sumant Diwakar
 

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.pptx
Precise Mya
 
Unit 2 Elements of C.pptx
Unit 2 Elements of C.pptxUnit 2 Elements of C.pptx
Unit 2 Elements of C.pptx
Precise Mya
 
Unit 1 Problem Solving.pptx
Unit 1 Problem Solving.pptxUnit 1 Problem Solving.pptx
Unit 1 Problem Solving.pptx
Precise Mya
 
Unit 6 Arrays.pptx
Unit 6 Arrays.pptxUnit 6 Arrays.pptx
Unit 6 Arrays.pptx
Precise Mya
 
Unit 5 Control Structures.pptx
Unit 5 Control Structures.pptxUnit 5 Control Structures.pptx
Unit 5 Control Structures.pptx
Precise Mya
 
Unit 2 Communication System.pptx
Unit 2 Communication System.pptxUnit 2 Communication System.pptx
Unit 2 Communication System.pptx
Precise 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

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
deeptiverma2406
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
Jisc
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
Mohammed Sikander
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
David Douglas School District
 

Recently uploaded (20)

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Best Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDABest Digital Marketing Institute In NOIDA
Best Digital Marketing Institute In NOIDA
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...How libraries can support authors with open access requirements for UKRI fund...
How libraries can support authors with open access requirements for UKRI fund...
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Multithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race conditionMultithreading_in_C++ - std::thread, race condition
Multithreading_in_C++ - std::thread, race condition
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Pride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School DistrictPride Month Slides 2024 David Douglas School District
Pride Month Slides 2024 David Douglas School District
 

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