SlideShare a Scribd company logo
Dinesh Maharjan, 2022
Programming in C
Input Output
Instructor: Dinesh Maharjan
2022
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
#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
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
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
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
• 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.
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
Unit 3 Input Output.pptx
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

PPTX
Introduction to Basic C programming 02
DOCX
C lab manaual
PDF
C programms
PPTX
Basic Input and Output
DOCX
cpract.docx
DOCX
Implementation of strassens
Introduction to Basic C programming 02
C lab manaual
C programms
Basic Input and Output
cpract.docx
Implementation of strassens

Similar to Unit 3 Input Output.pptx (20)

PPT
All important c programby makhan kumbhkar
PPTX
4. chapter iii
DOC
C basics
PPSX
Concepts of C [Module 2]
PDF
C Programming lab
PDF
String
PPTX
Input output functions
DOCX
Chapter 8 c solution
PPTX
DOCX
string , pointer
PPT
Unit 5 Foc
PDF
C language concept with code apna college.pdf
PPTX
Introduction about Low Level Programming using C
PDF
9.C Programming
PPTX
Najmul
PPTX
ภาษาซีพื้นฐาน
PPTX
Lecture_on_string_manipulation_functions.pptx
PPT
input
DOCX
Best C Programming Solution
DOCX
SaraPIC
All important c programby makhan kumbhkar
4. chapter iii
C basics
Concepts of C [Module 2]
C Programming lab
String
Input output functions
Chapter 8 c solution
string , pointer
Unit 5 Foc
C language concept with code apna college.pdf
Introduction about Low Level Programming using C
9.C Programming
Najmul
ภาษาซีพื้นฐาน
Lecture_on_string_manipulation_functions.pptx
input
Best C Programming Solution
SaraPIC
Ad

More from Precise Mya (6)

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

Recently uploaded (20)

PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PDF
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
PDF
AI-driven educational solutions for real-life interventions in the Philippine...
PDF
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
advance database management system book.pdf
PPTX
20th Century Theater, Methods, History.pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
HVAC Specification 2024 according to central public works department
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Introduction to pro and eukaryotes and differences.pptx
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
LDMMIA Reiki Yoga Finals Review Spring Summer
CISA (Certified Information Systems Auditor) Domain-Wise Summary.pdf
AI-driven educational solutions for real-life interventions in the Philippine...
Τίμαιος είναι φιλοσοφικός διάλογος του Πλάτωνα
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
advance database management system book.pdf
20th Century Theater, Methods, History.pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Paper A Mock Exam 9_ Attempt review.pdf.
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
FORM 1 BIOLOGY MIND MAPS and their schemes
HVAC Specification 2024 according to central public works department
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Weekly quiz Compilation Jan -July 25.pdf
Introduction to pro and eukaryotes and differences.pptx
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf

Unit 3 Input Output.pptx

  • 1. Dinesh Maharjan, 2022 Programming in C Input Output Instructor: Dinesh Maharjan 2022
  • 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
  • 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
  • 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.
  • 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