7 Input and Output in C Language Lyst7377
7 Input and Output in C Language Lyst7377
① About C
language
② print C)
③ Write your first program .
④ Escape Sequences
⑤ Format specifiers
⑥ scanfcl
Abontclanguage
① C is a block structured
programming language
② A can
have any
number of blocks
c
program
blocks are funding
outermost
③ Usually
for identification
④ function has some name
must be
⑦ If there is only one function its name
main C)
④ C is a case
lowercase
int a
5 ;
error
A-
← uppercase
← Global variable
int x
;
Global declaration
main c)
{ ← local variable
int a ;
Local declaration
f- I C)
{ Local variable
int b ; ←
Local declaration
}
Acticnstatement
① Input & output instructions
② Arithmetic Instruction
③ Control Instruction
standardt-nputos-outputdevikey.to
ard → standard Input
device
output
device
_%
_ogg• '
µ g.
standard output ÷
Monitor → .
device
aa•←§¥÷É
:/ .*Éd÷
-
↑:#
↑
in
/
output device Input
device
§ LCMC )
{
→
LCMCI ;
=
'
LCMC ≥
,
3
Output Instruction
#
"
) ;
"
-78
print Hello pointfc ,
{
pnntfc ) I
① to
print text
value variable
of
or
② to print a
y
an expression .
on the screen .
int Maine )
{
);
"
"
f- ( welcome
print
return 0 ;
}
Write a
program
to print welcome on
the screen .
int Maine )
{
f- (
"
welcome ); "
return 0;
}
Write a
program
to print lwekcmestudents
on the screen .
Print welcome onthefi.rs#
line and students on the second line .
s
/
welcome
);
"
"
welcome
pointfc " "
);
printfc in
"
f( students );
"
print
or
)
"
In students ;
f( welcome
"
print
Write a
program
to print lwekcmestudents
on the screen .
Print welcome onthefi.rs#
line and students on the second line .
{ "
welcomein
print /
0 ;
return
3
tscapesequences
In newline
It tab space
lb backspace
18 carriage return
if form feed
it print \
" "
\ print
' '
\ print
to value
Write a
program print
variable
of a .
{
int a -_ 5 ;
"
a) ;
""
5
printfl %d ,
}
);
" "
a
printf( a
Write to print value of
program
a
a variable .
◦
,
→
return 0 '
Format Stony
3
Foomatspecifiersl.cl
int
% C char
% ffloat
% If double
Write printf statement to print
following on
the screen .
① 56 print 7C"%d % ,
a
,
⑤ Sum
of 5 and 6 is 11
"
%d=%d",a biatb) ;
⑥ 5+6=11 print 7C id + ,
"
value of Id and value atb
④ pnntfc a is
ad
"
a b) ;
is
-
, ,
%d",qb,a+b);
"
following on
the screen .
printfc "a=%d b) ;
"
② a=5 and b=6 b=%d and ,
a
,
"
%d is %d a
%d and
printfl
"
of
,
sum
⑥ 5+6=11
,b ) ;
[
"
of bis %d a
is %d and value
"
print (-
value of a
,
b) ;
printfc"%d+%d=%d
"
> ,
a ,b , at
scan f- C)
scan f- C) predefined function
→
scant / %d .&-a) ;
"
"
↑
address of
write a
program to calculate sum
of
two
integers .
Write to calculate sum
of
a
program
two
integers .
int Maina
{ int a. b.ci
);
"
two numbers
printfc Enter
"
%d%d & a. d- b) i
" "
scan f- ( ,
-
C=a+b ;
,b , C ) ;
"
T.disi.cl
of %d and
"
a
pointfl sum ,
return 0 :