C Programming: Input and Output Operations, Study notes of Computer Science

A c program demonstrating various input and output operations using standard library functions such as printf, scanf, and others. It covers arithmetic operations on integers and floats, user input, and assignment statements.

Typology: Study notes

Pre 2010

Uploaded on 08/09/2009

koofers-user-rfl-1
koofers-user-rfl-1 🇺🇸

2

(1)

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1

!
-1190)
" #%$'&)(+*%,-&).%(0/21435#7648:97;<#=
>@?)?)A ,-;CB.<*%(D/EF9%*7(+$<G%3<H4I
-
J7K%L
=M.<(ON<HP3
K5K
.5A #%&
L
;%#5&)Q
>?)?)A ,';R/
Lally 9A
ST;<N
K
3%65;U/-VWV:VYX),'$-X)(
K
A X);5G<*-Z\[7,'97;<#76<]-Z\&);53^,<95A #762ZM_%_5`%a
)bcdfeghifjlk
mn0o
p qsrMtMu
v7w)x5yMz {
| }~  s}~
'
'@0-@'M0- )0)'s
tMu rMtMu
g
< + }+¡¢ }£) £)¡ ~
¤
~ ~ ¡ ¥'¦+§ ¨¢ }+£) £)¡ ~
© £)+ª ¢¡ «¬¡ §¢ }£) £)¡ ~
)®)¯)¯¯)°)±+²)²+°
)°)¯)¯³)´)®+°)+´
)±)¯)¯±)²)°+¯)±+²
¢¬µ
¤¤
¤'¶
· ¸ µ'¹0º7»
»¼
¤
½h'¬f
¡ § § ¾
¥-¿ § ¡
+¡ § §
+¡ § § +¾
»7§ ¦ ¨
¢ }+À
·+ ¡ÁM § ¡
 © £)+ª ¢¡ «¬¡ §¢ }£) £)¡ ~ Ã
µ'¦+Ä ¡ sÁM § ¡
 ^ + }¡¢ }£) £)¡ ~ Ã
ºÅ)¡ + ¦+§¡
ÆÇMÇ5ÈÉOÊËMÌ Ì ÉOÊËMÌ Ì ÉÍ Ç
º0Î+
ÏËMÐÑ ÒÊËMÌ Ì ÉÍ Ç
Ó ÔÕfj
man
Ö5×)Ø Ù\Ú
theFile
lpr printFile
ÛFØÜ^Ý2Þ ß\à
theFile
á
Ù'âWÝ'ßã%â:ß\Ú
ßäÚØ å:â
more theFile
ÛFØÜ^Ý2Þ ß\à
theFile
cat theFile
æFç ßèÙã%âFé%Ø ×)â\êÚ
á
× àOÚ
á
theDir
cd theDir
æ×)â2ßÚâ
theDir
mkdir theDir
ëFâ2å
áì
â
theFile
rm theFile
í
áì
â
fromFile
Ú
á
toFile
mv fromFile
toFile
æ
á
Ýà
fromFile
Ú
á
toFile
cp fromFile
toFile
î2ØÜÚ2ïØ Þ â\Ü
ls Operation
Command
ðñkMk lòôóõ'k j
öY÷øMù ø)úäû'ü
xemacs hw.c&
ýþ
nedit hw.c&
ýþ ÿ
hw.c
ý


ø)ú û<ü
gcc

 
hw.c
ö

äù ø)úäû'ü
hello
1.
Z

UB@;

.
!
%VW.%(
"
G
K
(s.%6%(s3
L
Z
2.
#
A #%,
$
*7G%;
&%
stdio.h>
3.
4.int main()
5.{
6. printf("hello
$'
¬Q
)(
7. printf("world\n");
8.
(M;5& *%(+#a
*(
9.}
pf3

Partial preview of the text

Download C Programming: Input and Output Operations and more Study notes Computer Science in PDF only on Docsity!

-1190)

[email protected])

@?)?)A ,-;CB .<%(D/EF9%7(+$<G%3<H4I

  • J7K%L

M.<(ON<HP

K

5K

5A #%&

L

;%#5&)Q

> ?)?)A ,';R/

Lally 9A ST;<N K

3 %65;U/-VWV:VYX),'$-X)(

K

AX);5G<*-Z[7,'97;<#76<]-Z&);53^,<95A #762ZM_%_5`%a

)bc dfeg hifjlk

pqsrMtMu mn0o

v7w)x5yMz {

|}~ €‚ƒ €„ s}~ † ‡'ˆ €ˆ

‰‹Š'Œ@ Ž0-@‘Œ'Œ ’‹“M”0•-– —)Ž˜”0—)'“sŽ

™tMu rMtMu

  ›šœžg 

¢¬μ ¤‡¤ ¤ ‡ '‡‹¶ ·¸μ'¹0º7»

½h'¬›f

+¡ §§

+¾ ƒ ƒ ¥-¿„ §¡^ ¡^ §§ ¾^ +¡ §§

¢„ }+À

·

+‚ ƒ¡ÁM„ §¡

©„£) +ª ¢¡ «¬¡ §¢ ˆ}£)‚ ˆ£)¡ ~Ã

μ '¦+Ä ¡ƒ€sÁM„ §¡

Ÿ^ˆ ƒ+„ }¡¢ ˆ}£)‚ ˆ£)¡ ~Ã

˜Å)¡ ƒ‚+€ ˆ¦+§ ¡

ÆÇMÇ5ÈÉOÊËMÌ ÌÉOÊËMÌ ÌÉÍ Ç

º0Î+„ €

ÏËMÐÑ ÒÊËMÌ ÌÉÍ Ç

Ó ÔÕ  f j

man

Ö

5×)Ø Ù\Ú

lpr printFile theFile

ÛFØ Ü^Ý2Þ ß\à theFile á

Ù

'âWÝ'ßã%â:ß\Ú

more theFile ßäÚØ^ å:â

Û

FØ Ü^Ý2Þ ß\à cat theFile theFile

æ Fç ßè٘ã%âFé%Ø ×)â\êÚ á

×àOÚ á cd theDir theDir

æ × )â2ßÚâ mkdir theDir theDir

ë Fâ2å á ˜ì

â rm theFile theFile

í á ˜ì

â fromFile

Ú

á toFile

mv fromFile

toFile

æ á

ݘà fromFile

Ú

á toFile

cp fromFile

toFile

î2Ø ÜÚ2ïØ Þâ\Ü ls

Command Operation

ðñkMk lòôóõ'k j

  • öY÷˜øMù ø)úäû'ü xemacs hw.c& ý˜þ nedit hw.c& ýþ ÿ

 hw.c

  • ‹ý'ø ø)ú û<ü gcc –     hw.c
  • öäù ø)úäû'ü hello

Z

UB@; .! %VW.%(" G

K

(s.%6%(s L

Z

A

%,$ *7G%;&%

stdio.h>

  1. int main()

  2. {

  3. printf("hello

$'¬Q)(

  1. printf("world\n");

M;5& %(+# a(

  1. }

l b     db4eh

  • Comment

á

â èÝèÞ ßèØ Ù çßÚ2Ú çâYÝ2× á

ã%×)ßèåØ Ü‹ï á

×<ß2Ùé çà:Ø ÚØÜ ÚçâYß˜àØ Ú%Ø Ü

  •     

Û

á

Ù

èâ2âï á

×âäÚ çâ:Ý2× á

ã%×)ß2åØ Ü ê á

å:Ý2Ø Þâ\é

  •  !#"%$ &#'( )#(+*+'#(+,- $(/. "+/!0 *+ !# !12 !- +, 3 +0 +!2+4/&0#56$  4 , */, (+.
  • Statement 7

Þ

Ø

Ù

èâ á

ï2ê á

é%âFÚ çß\ÚèÚâ2Þ Þ܋ê á

å:Ý8\Úâè×Ú á

Ýèâ2× ï á

×)å Ü á

å:âYß\êÚØ á

Ù

7

ÞYߘà0Ü@â2٘é â\éYØ Úç ßFÜ^â2å:Ø ê á

Þ

á

Ù9;: <;

  • =!>?+@/ !12- &#!#"A0 +!#.
  • Function 7

å á

é 8èÞ â á

ïÚMâèÙäê á

Ù\Ü^Ø ÜÚØ Ùã á

ï%ßFÜ^â\Ú á

ï

statements.

  • B - &#!"%0 +!#. ! 20 )#( )#(+$ $BC/, $'ED#, +1#, *+3GF main H printf

c ½k 4 Ô b 4JI

  • KMLGNCOQPSRUTVRQWXQRQYN RL[ZQ+]_^Q` ]Qacbedgf d2hQb?+dQi

printf bedcadc`dQjc]Qb;kQl h2mcdQb;kn]Q\Sb?k2Znh_oQ+l hQb;l hQm

characters.

  • pqdQaQl r%s[b;kn]Uk]Qi idctEdQ+i agoQ+dQmQ%ZQjub?dcbe+s[dQ^Qb v ZQ+l dQ^Q[]nf ZQoQ]g]QwQ^n]2hQf ]n[i lx]zy
  • \

#R/

Newline

X

E{Y.<$<A &)A .<#C,<*5($<.%(F3%&5& 9 7;PN%;56%A #5#7A # 76

.^?7& 9 7;4#7;|-&! A#7;<X

  • \

&/DEO3%N<XE}.~<;C,-*%(M$<.<( &).P& 9 7;C#7; |'&<&)3%NP$<&).

K

X

  • \

U/€ ;<(M& XEY.<*%#7GP&)97;4$'H-$^&);

L

N%;! X

‚ d< hƒ fh b „feh 

E

F.4?+.%(

L

K

(s;%$'$'A .<#7$

í Yß2٘àOÜÚßÚâ2å:â'Ù\Ú Ü@ß2×)âYå:â2×)âèÞ à

expressions.

  • †

L

3 !<.5(MG%;<(O.<?7.

K

;%(M3<&)A .<#%$4A $

?).$ .%VY;5G%XE{Y35(M;<#%& 9 7;%$<;<$@,<3%#

N5;C*5$<;%G%X

%H<.<3<(M;P#7.<&%$'7(M;$  .5.‡ *

K

A#EˆŠ‰‰ ‹Œ Ž ‘n’“V‰‹ ”?•– —”

˜”?‹™‹ ‹Œ ™‹šn›• ”?– œ$ K

_%_5`%] -- Decrement

++ Increment

í á

é 82Þ 8 \Ü

(remainder)

%

/^ Division

Multiplicatio n

-^ Subtraction

+^ Addition

Ÿž ¡£¢¥¤§¦6¡£ ;¨ª©¬«¥¦¥ž6¡£®¥ž¯±°2Ÿ²´³¶μ·¸¤¹«¥º;¦

  1. »e¼

×

)Ø Úçå:â\ÚsØ ê á

Ý2âè×)ß\Ú á

×Ü

¼ »

  1. ½

Ø

Ù

ê^Þ 8 \é%âS¾ stdio.h>

  1. int main()

  2. {

  3. printf("7+3=%d\n",7+3);

  4. printf("7-3=%d\n",7-3);

  5. printf("73=%d\n",73);

  6. printf("7/3=%d\n",7/3);

  7. printf("7%%3=%d\n",7%3);

  8. printf("7.0/3.0=%f\n",7.0/3.0);

×

)â\ÚA82×)Ù¿:

13.}

Variables

  • Variable †

L

P?).%(F

L

L

.5(MH4.5NÀ;<,^& XEÁY3<(MA 3 %N ;

L

L

*5$^&<$<&)3<(M&%VWA & 9 ;5& &);%(+$435#7G4,<.%#%&)35A # ;5& &);5($

G5A 6 <A &$$ 53^#7GP*5#7G%;%(+$',<.<(M;%$-X

ß ÂÂ2Ø ÂÄÃÅÂ\ê á

8 2ÙÚMâè×;Â number_of_points

 \êÆ+ÇÈÉÂÊ

  • Type

S

T9%3<&<& 9 7;E~<3%(+A 3 %N ;P(M;

K

(M;<$<;<#7& $'XP8 .<* GPN5; .<?

A#5&);%65;%( %? .%35& A# 76

K

.%A #%&%#5*

L

N%;%( ^,-973%(M3<,<&);<(" <$^& (MA # 76 

3 <#7G

L

3 5#%H4.5& 9 7;<($<X

  • int ËÌ ÍÎÏÐ ËÑCÎÒÓÍ ÔËÕÖÏ×;ËØ
  • Declaration

E

O; $@,<.

L

CK

A

 ; 5( 3 5N%.5*%&~<3<(MA 3 %N ;^$œ3%#7G & 9 7;^A (F& H K

;<X

  • int i,j;

ï sÞ á

ß\ÚèÜ82å:

Ù ñglf< b ÚcÛ4e

~ ';5(H& .<#76P? .%3<&)A # 76

K

.<#76PG%.%*7N$ ; .%A #%&

 . <#764? .53<&)A # 76 K

G5.<*7N! ; .%A #7&

 . .^#76P.5( .<#76 <#76PA #7&);%65;^( int

$'95.%(+&%A #7&);56%;5(

$'95.%(+&7.^(F$'97.<(M&

int

charater

M3¸~^;5(Hœ$'97.<&

integer)

char

?  .53%& A# 76

K

.%A #5&

float

int integer