SlideShare una empresa de Scribd logo
1 de 8
3




C

                                                          C

                                                          Standard

             Output File      Standard Input File   3-1




                    3-1

             Standard Input
File              Buffered



Standard Output
File




                              C       printf



Printf (“[             ”,[
3–2                   Output




                           Input           Output       3 -1

        3–1


               char               -                 c   %c
            short int            h                  d   %hd
                int               -                 d   %d
             long int          I or L               d   %Ld
               float              -                 f   %f
              double              -                 f   %f
           long doule             L                 f   %Lf




%[

                        3- 2

        3 -2

               %d                  %4d
   12          12                    12
123            123                 123
1234           1234                1234
12345          12345               12345
                               float

%[
printf(“%7.2f”,23.35000);
                                        5                   4

          1                             2

                      23.35



1. printf(“%d%c%f”,23, „z‟,4.1);



                      23z4.100000




2. printf(“%d %c %f”, 23. „z‟, 4.1);



           23 z 4.100000
                      1

3.        int num1 = 23;
char zee = „z‟;
float num2 = 4.1;
printf(“%d %c %f”, num1, zee, num2);



           23 z 4.100000
4.        printf(“%dt%ct%5.1f”, 23, „z‟, 14.2);
printf(“%dt%ct%5.1f”, 107, „A‟, 53.6);
printf(“%dt%ct%5.1f”, 1754, „F‟, 122.0);
printf(“%dt%ct%5.1f”, 3, „P‟, 0.1);



                      23                    z       14.2
                      107                   A       53.6
                      1754                  F       122.0
                      3                      P      0.1
5. printf(“The number is %6d”, 23);
The number is         23
        C




                                  Back-slash character       3-3

            3-3     Back-slash character


            „0‟         Null Character
            „a‟              Alert
            „b‟           Backspace
            „t‟           Horizontal
            „n‟             Newline
            „v‟           Vertical tab
             „f‟          Form feed
            „r‟         Carriage return
              „‟         Single quote
            „”‟          Double quote
            „‟            Backslash



1. printf(“%d %d %dn”, 44, 55);
44 55 0
                                 3                   2

2. printf(“%d %dn”, 44, 55, 66);
44 55
                                      2                  3    3



3. long int x = 444446766;
printf(“%dn”, x);
-18386


                                 Ld



                                       C    scanf
Scanf(“[               ”,[




                        3-3



                                            Enter



                                                    Error



1. 214 156 14z
scanf(“%d%d%d%c”, &a, &b, &c, %d);
                      14      z         c



           scanf(“%d%d%d %c”, &a, &b, &c, %d);
2. 2314 15 2.14
scanf(“%d %d %f”, &a, &b, &c);



3. 14/26 25/66
scanf(“%2d/%2d %2d/%2d”, &num1, &num2, &num3, &num4);



4. 11-25-56
scanf(“%d-%d-%d”,&a, &b, &c);



1. int a = 0;
scanf(“%d”,a);
printf(“%d/n”,a);
234                  (Input)
                                 0                      (Output)
                                         &       a

                                         error

2. float a = 2.1;
scanf(“%5.2f”,&a);
printf(“%5.2f”,a);




3. int a;
Int b;
scanf(“%d%d%d”,&a, &b);
Printf(“%d %d/n”, a, b);
5 10                 (Input)
                      5 10                   (Output)
                                     3                           2   scanf

            2                                             3



                                                     conio.h

getch                                                    1

                             Enter




            ch = getch();
getche                               getch



ch = getch();
getchar                                                      1

                                     Enter
ch = getchar(0;



        3-1              “Nothing”

                   3-1               “Nothing”




                  3-2
3-2

Más contenido relacionado

La actualidad más candente (18)

C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5C Programming Language Step by Step Part 5
C Programming Language Step by Step Part 5
 
New microsoft office word document
New microsoft office word documentNew microsoft office word document
New microsoft office word document
 
C programs
C programsC programs
C programs
 
week-18x
week-18xweek-18x
week-18x
 
C lab programs
C lab programsC lab programs
C lab programs
 
C Programming Language Part 4
C Programming Language Part 4C Programming Language Part 4
C Programming Language Part 4
 
Avl tree
Avl treeAvl tree
Avl tree
 
week-1x
week-1xweek-1x
week-1x
 
The solution manual of c by robin
The solution manual of c by robinThe solution manual of c by robin
The solution manual of c by robin
 
week-11x
week-11xweek-11x
week-11x
 
Intro to c programming
Intro to c programmingIntro to c programming
Intro to c programming
 
Tu1
Tu1Tu1
Tu1
 
โปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐานโปรแกรมย่อยและฟังชันก์มาตรฐาน
โปรแกรมย่อยและฟังชันก์มาตรฐาน
 
C Programming lab
C Programming labC Programming lab
C Programming lab
 
ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
Circular queue
Circular queueCircular queue
Circular queue
 
ภาษา C
ภาษา Cภาษา C
ภาษา C
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 

Destacado

Mane wk9 term 1 13pdf
Mane wk9 term 1 13pdfMane wk9 term 1 13pdf
Mane wk9 term 1 13pdf
takp
 
Turei week 8 term 3
Turei week 8 term 3 Turei week 8 term 3
Turei week 8 term 3
takp
 
Turei wk 2 term 3 13 pdf2
Turei wk 2 term 3 13 pdf2Turei wk 2 term 3 13 pdf2
Turei wk 2 term 3 13 pdf2
takp
 
ANZ Law Seminar _Law resources overview V2
ANZ Law Seminar _Law resources overview V2ANZ Law Seminar _Law resources overview V2
ANZ Law Seminar _Law resources overview V2
tinaarg
 
An analysis of the role played by the ‘China Import and Export Fair’ in Canto...
An analysis of the role played by the ‘China Import and Export Fair’ in Canto...An analysis of the role played by the ‘China Import and Export Fair’ in Canto...
An analysis of the role played by the ‘China Import and Export Fair’ in Canto...
wangqiongapp
 
Taite wk10 term 1 13 pdf one
Taite wk10 term 1 13 pdf oneTaite wk10 term 1 13 pdf one
Taite wk10 term 1 13 pdf one
takp
 
Mane wk8 term 1 13pdf
Mane wk8 term 1 13pdfMane wk8 term 1 13pdf
Mane wk8 term 1 13pdf
takp
 
Turei wk 1 term 3 13pdf
Turei wk 1 term 3 13pdfTurei wk 1 term 3 13pdf
Turei wk 1 term 3 13pdf
takp
 
Section C (Know your spelling)
Section C (Know your spelling)Section C (Know your spelling)
Section C (Know your spelling)
Rafidah Roslan
 
Turei wk2 term 2
Turei wk2 term 2Turei wk2 term 2
Turei wk2 term 2
takp
 
Outer banks
Outer banksOuter banks
Outer banks
efikmovy
 

Destacado (20)

T301
T301T301
T301
 
Mane wk9 term 1 13pdf
Mane wk9 term 1 13pdfMane wk9 term 1 13pdf
Mane wk9 term 1 13pdf
 
Turei week 8 term 3
Turei week 8 term 3 Turei week 8 term 3
Turei week 8 term 3
 
Wenerei wk 3 term 3 13pdf
Wenerei wk 3 term 3 13pdfWenerei wk 3 term 3 13pdf
Wenerei wk 3 term 3 13pdf
 
Turei wk 2 term 3 13 pdf2
Turei wk 2 term 3 13 pdf2Turei wk 2 term 3 13 pdf2
Turei wk 2 term 3 13 pdf2
 
ANZ Law Seminar _Law resources overview V2
ANZ Law Seminar _Law resources overview V2ANZ Law Seminar _Law resources overview V2
ANZ Law Seminar _Law resources overview V2
 
Ppt
PptPpt
Ppt
 
An analysis of the role played by the ‘China Import and Export Fair’ in Canto...
An analysis of the role played by the ‘China Import and Export Fair’ in Canto...An analysis of the role played by the ‘China Import and Export Fair’ in Canto...
An analysis of the role played by the ‘China Import and Export Fair’ in Canto...
 
Taite wk10 term 1 13 pdf one
Taite wk10 term 1 13 pdf oneTaite wk10 term 1 13 pdf one
Taite wk10 term 1 13 pdf one
 
One-min Intro to Spectator.do
One-min Intro to Spectator.do One-min Intro to Spectator.do
One-min Intro to Spectator.do
 
Mane wk8 term 1 13pdf
Mane wk8 term 1 13pdfMane wk8 term 1 13pdf
Mane wk8 term 1 13pdf
 
Midia Kit Brasil Game Day (English)
Midia Kit Brasil Game Day (English)Midia Kit Brasil Game Day (English)
Midia Kit Brasil Game Day (English)
 
Arvore Decisões - Discador windows - Bridge
Arvore Decisões - Discador windows - BridgeArvore Decisões - Discador windows - Bridge
Arvore Decisões - Discador windows - Bridge
 
Turei wk 1 term 3 13pdf
Turei wk 1 term 3 13pdfTurei wk 1 term 3 13pdf
Turei wk 1 term 3 13pdf
 
Section C (Know your spelling)
Section C (Know your spelling)Section C (Know your spelling)
Section C (Know your spelling)
 
Turei wk2 term 2
Turei wk2 term 2Turei wk2 term 2
Turei wk2 term 2
 
MODAL VERBS
MODAL VERBSMODAL VERBS
MODAL VERBS
 
Outer banks
Outer banksOuter banks
Outer banks
 
Lilianagbiu
LilianagbiuLilianagbiu
Lilianagbiu
 
LU分解について
LU分解についてLU分解について
LU分解について
 

Similar a บทที่ 3

ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
kramsri
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
sutharbharat59
 
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
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
kramsri
 
C basics
C basicsC basics
C basics
MSc CST
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐาน
Krunee Thitthamon
 

Similar a บทที่ 3 (20)

ภาษาซี
ภาษาซีภาษาซี
ภาษาซี
 
1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf1. Translation program#includestdio.h#includeconio.h#incl.pdf
1. Translation program#includestdio.h#includeconio.h#incl.pdf
 
Computer graphics programs in c++
Computer graphics programs in c++Computer graphics programs in c++
Computer graphics programs in c++
 
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’
 
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’
 
'C' language notes (a.p)
'C' language notes (a.p)'C' language notes (a.p)
'C' language notes (a.p)
 
Computer graphics lab assignment
Computer graphics lab assignmentComputer graphics lab assignment
Computer graphics lab assignment
 
C Programming Example
C Programming Example C Programming Example
C Programming Example
 
Simple C programs
Simple C programsSimple C programs
Simple C programs
 
คำสั่ง Switch
คำสั่ง Switchคำสั่ง Switch
คำสั่ง Switch
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
 
Concepts of C [Module 2]
Concepts of C [Module 2]Concepts of C [Module 2]
Concepts of C [Module 2]
 
comp2
comp2comp2
comp2
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
 
c programs.pptx
c programs.pptxc programs.pptx
c programs.pptx
 
C-programs
C-programsC-programs
C-programs
 
C basics
C basicsC basics
C basics
 
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชันตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
ตัวอย่างการเขียนโปรแกรม โดยใช้ฟังก์ชัน
 
C programming BY Mazedur
C programming BY MazedurC programming BY Mazedur
C programming BY Mazedur
 
ภาษาซีพื้นฐาน
ภาษาซีพื้นฐานภาษาซีพื้นฐาน
ภาษาซีพื้นฐาน
 

Último

Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

บทที่ 3

  • 1. 3 C C Standard Output File Standard Input File 3-1 3-1 Standard Input File Buffered Standard Output File C printf Printf (“[ ”,[
  • 2. 3–2 Output Input Output 3 -1 3–1 char - c %c short int h d %hd int - d %d long int I or L d %Ld float - f %f double - f %f long doule L f %Lf %[ 3- 2 3 -2 %d %4d 12 12 12 123 123 123 1234 1234 1234 12345 12345 12345 float %[
  • 3. printf(“%7.2f”,23.35000); 5 4 1 2 23.35 1. printf(“%d%c%f”,23, „z‟,4.1); 23z4.100000 2. printf(“%d %c %f”, 23. „z‟, 4.1); 23 z 4.100000 1 3. int num1 = 23; char zee = „z‟; float num2 = 4.1; printf(“%d %c %f”, num1, zee, num2); 23 z 4.100000 4. printf(“%dt%ct%5.1f”, 23, „z‟, 14.2); printf(“%dt%ct%5.1f”, 107, „A‟, 53.6); printf(“%dt%ct%5.1f”, 1754, „F‟, 122.0); printf(“%dt%ct%5.1f”, 3, „P‟, 0.1); 23 z 14.2 107 A 53.6 1754 F 122.0 3 P 0.1 5. printf(“The number is %6d”, 23);
  • 4. The number is 23 C Back-slash character 3-3 3-3 Back-slash character „0‟ Null Character „a‟ Alert „b‟ Backspace „t‟ Horizontal „n‟ Newline „v‟ Vertical tab „f‟ Form feed „r‟ Carriage return „‟ Single quote „”‟ Double quote „‟ Backslash 1. printf(“%d %d %dn”, 44, 55); 44 55 0 3 2 2. printf(“%d %dn”, 44, 55, 66); 44 55 2 3 3 3. long int x = 444446766; printf(“%dn”, x); -18386 Ld C scanf
  • 5. Scanf(“[ ”,[ 3-3 Enter Error 1. 214 156 14z scanf(“%d%d%d%c”, &a, &b, &c, %d); 14 z c scanf(“%d%d%d %c”, &a, &b, &c, %d); 2. 2314 15 2.14 scanf(“%d %d %f”, &a, &b, &c); 3. 14/26 25/66 scanf(“%2d/%2d %2d/%2d”, &num1, &num2, &num3, &num4); 4. 11-25-56 scanf(“%d-%d-%d”,&a, &b, &c); 1. int a = 0; scanf(“%d”,a); printf(“%d/n”,a);
  • 6. 234 (Input) 0 (Output) & a error 2. float a = 2.1; scanf(“%5.2f”,&a); printf(“%5.2f”,a); 3. int a; Int b; scanf(“%d%d%d”,&a, &b); Printf(“%d %d/n”, a, b); 5 10 (Input) 5 10 (Output) 3 2 scanf 2 3 conio.h getch 1 Enter ch = getch(); getche getch ch = getch(); getchar 1 Enter
  • 7. ch = getchar(0; 3-1 “Nothing” 3-1 “Nothing” 3-2
  • 8. 3-2