際際滷

際際滷Share a Scribd company logo
Standard I/O
Use of printf() and scanf()
 printf() Print Format 曙企, 覃伎 伎 豢ロ  
 覈(矧)企.
printf(format string.., argument list);

[Ex]
#include <stdio.h>
int main() {
int n ;
n = 25 * 10;
printf(%d, n);
}
[Ex]
printf(%c%c%c, a, b, c );
printf(%s, def );

/* 250  豢ル. */

/* abc 螳 豢ル. */
/* def 螳 豢ル. */

2
Use of printf() and scanf()
 Conversion characters (format string)
%c

character (覓語)

printf(%c, a);

%d

decimal integer (10讌襦豢) printf(%d, 100);

%x

Hexadecimal integer
(16讌襦豢)

printf(%x, 100);

%o

Octal integer (8讌襦豢)

printf(%o, 100);

%u

Unsigned decimal (襦豢)

printf(%u, 100);

%e

floating point number in
scientific notation

printf(%e, 1.234);

%f

floating point number

printf(%f, 1.234);

%g

e-format f-format

printf(%g, 1.234);

%s

string (覓語)

printf(%s, C-book);
3
Use of printf() and scanf()
 The Use of printf() : integer %d
printf( %md, a );
printf( %-md, a);

/*m .るジ讓曙 */
/*m . 殊曙 */

[Ex]
a = 12;
printf(%5d%-5d%dn ,a, a, a+11);

12^^^^^^1223

 %5d襦 豢 : 12^^^
( 5襴 殊曙襦 豢, れ 螻糾 朱 螻給葦朱 豈)
 %-5d襦 豢 : ^^^12
( 5襴 るジ讓曙襦 豢,  螻糾 朱 螻給葦朱 豈)
 %d襦 豢 : 23
(a +11 螳 23 蠏碁襦 豢)

4
Use of printf() and scanf()
 The Use of printf() : float %f
printf( %m.pf, a );
printf( %-m.pf, a);

/*m, p .るジ讓曙 */
/*m, p . 殊曙 */

[Ex]
83.1260^^83.126083.126000^^^83.13
a = 83.126;
printf(%8.4f%-8.4f%f%-7.2fn, a, a, a, a );
 %8.4f : 83.1260^
(  豐 8襴 襯 豢ロ  危 4襴蟾
讌 . )
 %-8.4f : ^83.1260
(%8.4f  , 蠏碁 襦 誤 るジ讓曙朱 )
 %f
: 83.126000
(豺語    危 6襦 豢)
 %-7.2f : ^^^83.13
(7襴 覲伎  危 2襴-覦襴, るジ讓 )
5
Use of printf() and scanf()
 Use of scanf()
 scanf() - key board襦覿 data襯  覦蠍   矧
.
scanf(format string.., argument list);
%c

character (覓語)

scanf(%c, &a);

%d

decimal integer (10讌)

scanf(%d, &a);

%f

floating point number (float)

scanf(%f, &a);

%lf

floating point number (double)

scanf(%lf, &a);

%Lf

floating point number (long double)

scanf(%Lf, &a);

%s

string (覓語)

scanf(%s, &a);

6
Use of printf() and scanf()
[Ex]
#include <stdio.h>
int main() {
int n ;
printf(Enter number : );
scanf(%d, &n);
printf(You entered : %d, n);
return 0;
}

Enter number : 10
You entered : 10
7
Ad

Recommended

[覈磯血惨] 2覯讌 - 一 (螻旧 ろ)
[覈磯血惨] 2覯讌 - 一 (螻旧 ろ)
Myeongun Ryu
覦 螳覦 ろ 誤 1覿
覦 螳覦 ろ 誤 1覿
mosaicnet
2. 界庚語伎 蠍磯蓋
2. 界庚語伎 蠍磯蓋
SeonMan Kim
ES6: RegExp.prototype.unicode 危危蠍
ES6: RegExp.prototype.unicode 危危蠍
Ohgyun Ahn
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(1)
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(1)
旧價拘磯
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(3)
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(3)
旧價拘磯
2 1. variables & data types
2 1. variables & data types
Modern Effective C++ Item2 Understanding Auto type deducing
Modern Effective C++ Item2 Understanding Auto type deducing
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(2)
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(2)
旧價拘磯
[170327 1譯殊姶]C語 A覦
[170327 1譯殊姶]C語 A覦
arundine
4. loop
4. loop
. Ruvendix
C語 一一 螳螻狩 蟆
C語 一一 螳螻狩 蟆
jaypi Ko
15 3 scanf-蠍一
15 3 scanf-蠍一
Changwon National University
Modern effective c++ 覈 3
Modern effective c++ 覈 3
ssuser7c5a40
襦蠏碁覦 覦 れ Chap2
襦蠏碁覦 覦 れ Chap2
dktm
譴 豢
譴 豢
. Ruvendix
14. fiile io
14. fiile io
G+ Summer C Study 20130703(1殊姶)
G+ Summer C Study 20130703(1殊姶)
Jake Yoon
蟆襦蠏碁覦覓 3譯殊姶
蟆襦蠏碁覦覓 3譯殊姶
Yeonah Ki
HI-ARC PS 101
HI-ARC PS 101
Jae-yeol Lee
= ≡ =梶 C
= ≡ =梶 C
Heesuk Kang
遺襭
遺襭
koominsu
G+ Summer C Study 20130709(3殊姶)
G+ Summer C Study 20130709(3殊姶)
Jake Yoon
Basic study 4谿
Basic study 4谿
Seonmun Choi
11. array & pointer
11. array & pointer

More Related Content

What's hot (9)

Modern Effective C++ Item2 Understanding Auto type deducing
Modern Effective C++ Item2 Understanding Auto type deducing
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(2)
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(2)
旧價拘磯
[170327 1譯殊姶]C語 A覦
[170327 1譯殊姶]C語 A覦
arundine
4. loop
4. loop
. Ruvendix
C語 一一 螳螻狩 蟆
C語 一一 螳螻狩 蟆
jaypi Ko
15 3 scanf-蠍一
15 3 scanf-蠍一
Changwon National University
Modern effective c++ 覈 3
Modern effective c++ 覈 3
ssuser7c5a40
Modern Effective C++ Item2 Understanding Auto type deducing
Modern Effective C++ Item2 Understanding Auto type deducing
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(2)
貊語拘 C&JAVA 蠍一螻殊 C襦蠏碁覦(2)
旧價拘磯
[170327 1譯殊姶]C語 A覦
[170327 1譯殊姶]C語 A覦
arundine
4. loop
4. loop
C語 一一 螳螻狩 蟆
C語 一一 螳螻狩 蟆
jaypi Ko
Modern effective c++ 覈 3
Modern effective c++ 覈 3
ssuser7c5a40

Similar to 2 3. standard io (20)

襦蠏碁覦 覦 れ Chap2
襦蠏碁覦 覦 れ Chap2
dktm
譴 豢
譴 豢
. Ruvendix
14. fiile io
14. fiile io
G+ Summer C Study 20130703(1殊姶)
G+ Summer C Study 20130703(1殊姶)
Jake Yoon
蟆襦蠏碁覦覓 3譯殊姶
蟆襦蠏碁覦覓 3譯殊姶
Yeonah Ki
HI-ARC PS 101
HI-ARC PS 101
Jae-yeol Lee
= ≡ =梶 C
= ≡ =梶 C
Heesuk Kang
遺襭
遺襭
koominsu
G+ Summer C Study 20130709(3殊姶)
G+ Summer C Study 20130709(3殊姶)
Jake Yoon
Basic study 4谿
Basic study 4谿
Seonmun Choi
11. array & pointer
11. array & pointer
Ch.14 螳c v0.6
Ch.14 螳c v0.6
麹 蟾
C 語 ろ磯 05 - 豢
C 語 ろ磯 05 - 豢
Yu Yongwoo
C語 れ願蠍
C語 れ願蠍
jaypi Ko
C語 れ願蠍
C語 れ願蠍
jaypi Ko
Python3 brief summary
Python3 brief summary
HoChul Shin
2013 C++ Study For Students #1
2013 C++ Study For Students #1
Chris Ohk
Python vs Java @ PyCon Korea 2017
Python vs Java @ PyCon Korea 2017
Insuk (Chris) Cho
襦蠏碁覦 覦 れ Chap2
襦蠏碁覦 覦 れ Chap2
dktm
14. fiile io
14. fiile io
G+ Summer C Study 20130703(1殊姶)
G+ Summer C Study 20130703(1殊姶)
Jake Yoon
蟆襦蠏碁覦覓 3譯殊姶
蟆襦蠏碁覦覓 3譯殊姶
Yeonah Ki
= ≡ =梶 C
= ≡ =梶 C
Heesuk Kang
G+ Summer C Study 20130709(3殊姶)
G+ Summer C Study 20130709(3殊姶)
Jake Yoon
Basic study 4谿
Basic study 4谿
Seonmun Choi
11. array & pointer
11. array & pointer
Ch.14 螳c v0.6
Ch.14 螳c v0.6
麹 蟾
C 語 ろ磯 05 - 豢
C 語 ろ磯 05 - 豢
Yu Yongwoo
C語 れ願蠍
C語 れ願蠍
jaypi Ko
C語 れ願蠍
C語 れ願蠍
jaypi Ko
Python3 brief summary
Python3 brief summary
HoChul Shin
2013 C++ Study For Students #1
2013 C++ Study For Students #1
Chris Ohk
Python vs Java @ PyCon Korea 2017
Python vs Java @ PyCon Korea 2017
Insuk (Chris) Cho
Ad

More from (20)

15 3. modulization
15 3. modulization
15 2. arguement passing to main
15 2. arguement passing to main
13. structure
13. structure
12 2. dynamic allocation
12 2. dynamic allocation
12 1. multi-dimensional array
12 1. multi-dimensional array
10. pointer & function
10. pointer & function
9. pointer
9. pointer
7. variable scope rule,-storage_class
7. variable scope rule,-storage_class
6. function
6. function
5 2. string processing
5 2. string processing
5 1. character processing
5 1. character processing
15 1. enumeration, typedef
15 1. enumeration, typedef
3 2. if statement
3 2. if statement
3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib
2 2. operators
2 2. operators
Goorm ide 蟲′覯 for skku()
Goorm ide 蟲′覯 for skku()
蟲襴 蠍磯蓋 螳襭
蟲襴 蠍磯蓋 螳襭
Goorm ide 螳 殊企(蟲′ 覯)
Goorm ide 螳 殊企(蟲′ 覯)
W14 chap13
W14 chap13
13th chapter12 slide
13th chapter12 slide
15 3. modulization
15 3. modulization
15 2. arguement passing to main
15 2. arguement passing to main
13. structure
13. structure
12 2. dynamic allocation
12 2. dynamic allocation
12 1. multi-dimensional array
12 1. multi-dimensional array
10. pointer & function
10. pointer & function
9. pointer
9. pointer
7. variable scope rule,-storage_class
7. variable scope rule,-storage_class
6. function
6. function
5 2. string processing
5 2. string processing
5 1. character processing
5 1. character processing
15 1. enumeration, typedef
15 1. enumeration, typedef
3 2. if statement
3 2. if statement
3 1. preprocessor, math, stdlib
3 1. preprocessor, math, stdlib
2 2. operators
2 2. operators
Goorm ide 蟲′覯 for skku()
Goorm ide 蟲′覯 for skku()
蟲襴 蠍磯蓋 螳襭
蟲襴 蠍磯蓋 螳襭
Goorm ide 螳 殊企(蟲′ 覯)
Goorm ide 螳 殊企(蟲′ 覯)
W14 chap13
W14 chap13
13th chapter12 slide
13th chapter12 slide
Ad

2 3. standard io

  • 2. Use of printf() and scanf() printf() Print Format 曙企, 覃伎 伎 豢ロ 覈(矧)企. printf(format string.., argument list); [Ex] #include <stdio.h> int main() { int n ; n = 25 * 10; printf(%d, n); } [Ex] printf(%c%c%c, a, b, c ); printf(%s, def ); /* 250 豢ル. */ /* abc 螳 豢ル. */ /* def 螳 豢ル. */ 2
  • 3. Use of printf() and scanf() Conversion characters (format string) %c character (覓語) printf(%c, a); %d decimal integer (10讌襦豢) printf(%d, 100); %x Hexadecimal integer (16讌襦豢) printf(%x, 100); %o Octal integer (8讌襦豢) printf(%o, 100); %u Unsigned decimal (襦豢) printf(%u, 100); %e floating point number in scientific notation printf(%e, 1.234); %f floating point number printf(%f, 1.234); %g e-format f-format printf(%g, 1.234); %s string (覓語) printf(%s, C-book); 3
  • 4. Use of printf() and scanf() The Use of printf() : integer %d printf( %md, a ); printf( %-md, a); /*m .るジ讓曙 */ /*m . 殊曙 */ [Ex] a = 12; printf(%5d%-5d%dn ,a, a, a+11); 12^^^^^^1223 %5d襦 豢 : 12^^^ ( 5襴 殊曙襦 豢, れ 螻糾 朱 螻給葦朱 豈) %-5d襦 豢 : ^^^12 ( 5襴 るジ讓曙襦 豢, 螻糾 朱 螻給葦朱 豈) %d襦 豢 : 23 (a +11 螳 23 蠏碁襦 豢) 4
  • 5. Use of printf() and scanf() The Use of printf() : float %f printf( %m.pf, a ); printf( %-m.pf, a); /*m, p .るジ讓曙 */ /*m, p . 殊曙 */ [Ex] 83.1260^^83.126083.126000^^^83.13 a = 83.126; printf(%8.4f%-8.4f%f%-7.2fn, a, a, a, a ); %8.4f : 83.1260^ ( 豐 8襴 襯 豢ロ 危 4襴蟾 讌 . ) %-8.4f : ^83.1260 (%8.4f , 蠏碁 襦 誤 るジ讓曙朱 ) %f : 83.126000 (豺語 危 6襦 豢) %-7.2f : ^^^83.13 (7襴 覲伎 危 2襴-覦襴, るジ讓 ) 5
  • 6. Use of printf() and scanf() Use of scanf() scanf() - key board襦覿 data襯 覦蠍 矧 . scanf(format string.., argument list); %c character (覓語) scanf(%c, &a); %d decimal integer (10讌) scanf(%d, &a); %f floating point number (float) scanf(%f, &a); %lf floating point number (double) scanf(%lf, &a); %Lf floating point number (long double) scanf(%Lf, &a); %s string (覓語) scanf(%s, &a); 6
  • 7. Use of printf() and scanf() [Ex] #include <stdio.h> int main() { int n ; printf(Enter number : ); scanf(%d, &n); printf(You entered : %d, n); return 0; } Enter number : 10 You entered : 10 7