Vous êtes sur la page 1sur 31

 

  
National University of
AlRIBAT
( )   
Khartoum Branch

 

Structural programming
 
C language
  !"
Search in the c programming
language
      : 

: 
:(Introduction)
: ! "#
1
*. %&  &/, $!  0 & *. -&  ,
$!  %&' ( ) * +#
! !) 0 0 ' )2 (345 & , (67 $! *  8
:(C language)9& 6
;# #@' ;  * !' ' <4 '  =>?  : "5 6 9:
(A4"  ;  5 (4  /#"
:9& 6 34', (@8
Unix C 84/ $D8 "# c 6 /45 *@/3 C8 , 14&4' 02 0 2 $B
52 0 / GH I  ! %!6 14 ' 1
* 6 (E: 34 F23 GH
O82, .c 6 PQR. 1972 $ 9) .B
OB, *), LMN B J (#2 K5
3@/3 0'3 !BQ5 $B 9 BCPL 6 0 @ !&S8 12, bI
6 0 @
GH Basic combined programming language 0 (T *:, 1967 $
$ 9) 14&4' 02 :/45 $B 9 ;8# U48 4: 06 05 PS 12
Bell 2 9)  / 12 GHBell#T  % 0 BH EM GH 1969
X, C  4: /F"8W 6 9)B   9/ VE, c 12, telephone
Z5 B( ! YS7,) 0/5, C8 0 2 37
1978$ *), C 6 ! &' #
!+ [2
The C Programming Language
K&R C T&+5 , [  12, ! * J\  #/ VE,
6 I  ]2 1
5 8
E :  &' 9) #&, (Kernighan&ritche)
_#7
*H ST ^&8 9) I,, ;#  /4' *. <
VE, #2  @5 9&
c6 B T&8 Z/' *. <
E:, !`5 J )4 > ^&+ X' 0 2
(T *:, ANSI c[ O , 9& 6  T&+ PQR. %'1989$ 9)
 /N +R4 " <Standards Institute American National 0
%' /  ,  D+ , /   /N +R4 +" 05 1,5, / 
3M *:,ISO[ O , % L 8
ZT 9) B c6 PQR.
0 *@ a5 ST O82,International Organization for Standization
:;F  ( C 6, K&RT&8
<4& * !T5 ;  * 9& 6 <4 ':Flexibility8,  b1
(6@ %D8 "5)aST+
-F" 3 K5 52 b2
U48
ZT * K8# ES+',  \' 0 /:portability+ 5B b3
(F!\N
:K8#
,
K#  45 O#2 (Source code);  0  4 " Z74  2 4:
ES+ 5B ;"5 Z74
: ( c 5 K8#  /, (Executable software)
V3  Z  L@8. !) %/:K8# 52 H*
:(Source code)V3  Z 
O#2, +  ! LN *   \4' 9 ,N ,
;  0 & 4:
1&8W 6 0 #/> 65
e 6 *. K8#  \' !) %/,:(Compiling) \ H*
:(Compilers); \ 
6 *. 9 <4&  6 0 V3  Z  /4 5 $4' K5 0 (3# 9:
* <4 / VE Object file *f6 Z  XE5 "+ (*8N <4& )e
V3  Z  ;  5 ; '
:ES+ H*
Linkerg5
0 `' 9 f ;S  J K8# *f6 Z  g53 *  / K85 4:
VE Executable file VES+ Z  4' 9) T&  #  I,
K8# -!+ K-+ * <4 /
:C 6 $  !
Header files
Preprocessor Directive
Main Function

:c(Data type) 6 *) ;8# U48


; 2 , ,H) $B3  ! ' * O+#
!5 C)H , integer(/@ ;Q !5 C)  7 14 ' 1 0 / $B3,b
float(/@ Q
b:;6 
0   LF\ M (  ;8# U48
a5 ]  $T&' ;) 9:
ES+ ;3# 9) :34!h #B !+ 1Q W "/, (2E 9) H& F"  K8#
,
H, 6  % i#/ ;8# U48  8 6  0 1Q W, statements
.R4+ 7S5 9!+/, ]2

b:syntax  6


Data type variable name;
Data type var1, var2, var3,……;
int   7 ;8# (2E 9) H& F"  1Q .
float V@ , 9H 6 0 H& F"  1Q .
char c ;Q, ,  0 H& F"  1Q .
b:I]
#include<stdio.h>
Void main ( )
{
Int x;
Float s;
Char c;
X=19;
F=18.23;
C=a;
Printf(“\n %d %f %c”,f,x,c);
Printf(“\n %d”,x);
b:O54]
K 8# ES+' L+k
O5]  B 9) 6 0 / , )H Q ,
$B3
. 14 '
:0/5  !S/' %/,
6 EM/,  \ #B  i\4 b1
#define const-name value
i 5 O5] % I#. %/  \ L+k
b2
Const data type valuable name=value;
#include<stdio.h>
#define ch, a ;
#define num 134
Void main( )
Const char 2=,b;
Const in mm2=276
Printf (“%c ”, ch );
Printf (“ %d”,num);
Printf (“%c”,ch2);
Printf(“%d”, num2);
}
c4 &  <  O/#5 4R 6  U48
H, F3 , H 1 char *)H
32768b32768 2 int B _ 7
b2014704830648 4 long /4R _ 7
2014704830648
E+38-e-38 4 float *H
E+308-e308 8 doubleZ `*H

.g) H 0/FT _/ 6 <


: H U48 0 6
( /@ Q i5 C )_ 7 %B3 0/FT _/ 6 <
: _ 7 U48 0 6
Zf _ 7 %B3 1FT/ <
J&/ <
:(Long)/4R 0 , _ 7 U48 0 6
#2
! ' * $B3N O82 . U4+ E:  &/, < _  6 
% K8# 1. 0 %>5 mRM K-8 *  + ., T  H % 0
6.33 ] /@ 34&  #/ *H %B3 0/FT _/ 6 <
: *H 6
*  6  Zf *H %B3 1FT/ 1
J&/ <
: Z ` *H 6
<
i+ o,@ 6  % J`T/ :  n6  in &' •
$B3
,
,H X 5 6   / %k  5 6 
#/ 1
"/b
hp 6  0 ZT/HP 6 ) (# , (6 ,  05 %\  PS/b
0/6 K8#  :#/ K8# *) Q  p)
(A4"  ;   0 i 2 %p5 6  14 / 
"/b
:0 B 83  $T&', :Relational operators 83  ;kq ٢
"n+ ] kq 
I F
1 100>1 > greater than 0 #2

1 10<8 < less than0 S7

0 10= =8 == equal to <,&/


1 10! =8 != not equal to <,&/ 
0 100<=8 <= less than or <,&/ ,
0 B

equal to
0 100>=9 >= greater than or ,&/ ,
0 #2

equal to

Logical operator+  ;kq  -0

"+ I] F kq 


1 10 > 8 && 9 > && And ,
7
0 1 0 < 8 || 7 < 8 || Or ,
1 ! (10 = = 8 ) ! NOt 
:c6 *) 5&  4
use $T Group 
CombinationJ " +
IPO c b
Quotient  & /
Beatings[` *
The rest of  & *B5 %
division

input and output tMW, IMW I,


printf( ) @ *  # 
tM, IM c@8 +A K85 5 5 $48 4
#include<stdio.h>
void main()
{ printf(“hello world”);
return 0; }
hello  \  #R, ES+',  \5 4 / GH *& 65  / K85 g&5 E: /
#include<stdio.h>5 I, &, consoleI m5 *) @ * world
4: +: i  3! Z 1
GH header file * Z  L  4:,
 !+ ;S  0  L  $T&' *!) include  2 
(stdio.h)
* <4 / Z, (string.h) )  IQ& J + I, (time.h) 0F
. (math.h) f/ I, J \
 4:,standard input output 0 4M 4:, stdio.h * Z 
* Z 
6 K85 V
9) !+ L+6W 0 / , Y \ %! LF"  E:,:main()+/,
K8# &-   9:, 9&
main  /!8, /5  !8 0 2 *,},{0Q +/,
 #R * 4/ VE4: LF"  E:, printf(“hello world”);LF\ *'/ %k
 L9  # &-   9: (printf)   1
GH @ * ;\T 
$
(stdio.h)3! Z L . 0 5  ! T. + , $T&   *
* i #R %/ 4 VE $Q  4!) u+ 9Q 05 34  $Q 
$ + i8
GH :2 0 5Q) & /!8 9) R4+  7S 
. @
9' !8
R4+  7S 0 (-S,.
gM 3 &S  X/ 4  v2
9:,.i/ VE & I8 "/, &  E: 0 L!8W %' B i8
&S  (3.
!+ 14 ' LMN > 1
GH  ' 1
5  +B  2
 /S   J\/ 4 K8# 1
9+' 9:, :( return 0 ;)
vE: O82 . .  5 ! 4' 1
"/ 9& 6 9) I, 1
GH (main)
  B ( p5 #'  
: 9& 65 K85 V
52 + AQ o,@ a5
J&'  X8
GH 3! Z $ L p5 9& 6 9) K85 V

#/ 1
5b
I],.  i5 wT3! Z $ L . 5 . X"85 9) I ,  &' 1
1

3! Z $ (printf())L . 1,   +T. 4 X  * U


M 3 9/ 4 K8# 1p) (studio.h)
.K# J \ 9)(main ())  2 0 5 b
4: K8# %&"5 9+8, R4+ 7S5 K8# %&\ 9)  2 9!+/ 1
5 b
({ }). 0Q 05 34  LF"
:/\  *. I8x (\n) Q $T.
, / VE & *. 9  & 0 q  +' 9  Q vE: $T&'
:! % /R 0#/ 9 I] 
#include <stdio.h>
main ()
{
printf(“welcome to the world of c\nI hope you enjoy
with it. \n”);
return 0;}
ES+' 5 1
. H ,  9)  %" O82 z5& 4  1
0 i8
yH
0  .0, (\n)Q + TW X , 0/ 9) tT _#7
K8#
/' VE 34&  V
(\n\n\n) ] /\  Q 0 ]2
$T&8 1

u+ /!8 9) Q vE: J`' 1


0 / `/
,. vT/ 1
q 
Printf(“welcome to the world of c \n”);
I,", ; 5 * &' 9:, 9& 6 9) ; Q vE: 0 / {+: \4/,
;  vE: 0#/ 9
=6 F
/\  *. q  +' \n
* U (‘)Q  #5 $4' Q vE: \‘
] ;Q ]2
1
yH, @
;3
. :>, %:SW ;Q
1
5Q) $T&   * U ! #R
#& , -  R@5 B4#& 14 '
;Q vE: ]2
1
4/ X  9)
!8
GH 9& 6 #B 0 T&
.  5 $4' !8
&S  9) )
(“). #5 $4' \“
(?) #5 $4' \?
\t

:@ * ;6  %B  #R


  ;8# U48   + 42
$T&' ;6 5 (4\4  %  #
5 ! #R
print f ()
printf ( " % d “ , a ) ;
printf ( " % f “ , b ) ;
vE! *   *. D+/ % Q 6 %\ 5/ + I]   E: *)
#/, . Q
0 0 U4+'  / H 2, Q 5 (4\4   Z74'   E:
;8#
;8# U48
 #R 42
_f4/ * I,",
I] $T F
printf ( " % d “ , - _ 7 * B3 O5k ,
6  Z74' %d
10) ( Signed decimal
integer ) int
printf ( “ % p “ , 507 *H * B3 O5k ,
6  Z74' %f
) ( floating
point ) float
printf ( “ % c “ , “ a ( H, H ) O5k ,
6  Z74' %c
“) char Single character
printf ( “ % s “ , “ is ]2
,
H )H (3# Z74' %s
“)

*Scanf ( )  IMW 


CS8 EM' *:, ;8# U48
J \ IMp5 _ C' * &- IMW  *:
(H, IQM 0 ;8# IM5 _ &', Print f ( )  :EM' * ;Q 
(keyboard)  IM
# include < stdio.h >
main ( )
{
int a , b , c ;
float r , s , t ;
char name [10];
printf ( " \n \n enter your name : " ) ;
scanf ( " % s " , name ) ;
printf ( " a = " ) ;
scanf ( " % d " , & a ) ;
printf ( “ b = " ) ;
scanf ( % d " , & b ) ;
printf ( " r = " ) ;
scanf ( " % f " , &r ) ;
printf ( " s= " ) ;
scanf ( " % f " & s ) ;
printf ( " \n welcome % s " , name ) ;
printf ( " \n \n c = a + b = % d " , a + b ) ;
printf ( " \n \n t = r + s = % d " , r + s ) ;
}
a , b , c , r , s , t , name ;6  0 1Q W %/b
enter your name printf()  J#' b
6  *) !S8, $T&  !M/ * )  (3# scan f ( ) #&'b
<MN ;6  XE2 name...
  7  Bscan f ( )( “ % d " , &a )  *) scan f ( )  #&'b
a6  9) !8FT',
& #q  *+n #
*+ 5 a 6  *) i84+ 1FT  1  *)      0/FT' *+': &a
6  "' & Q GH   i) 1FT' <E 1  14+ *. @/ a 1

1  14+ *. @/


:K'+
enter your name : ahmed
a=5
b = 1٠
r = 2٠
٠s = 3
welcome ahmed
c = a + b = 15
t = r + s = 50
H IM. I,
)  ;3#, , 2 ;8# 0 7M U48
J ' <M
I, {+:
*:,
putchar()}getchar ( ) , getche ( ) , getch ( )
:getchar()
I+5 _ &', 5  5 @ *   !D/, H, H IM $T&'
M ) , Enter cS * $T&  g6f   *  *
stdio.h # 
char a;
a=getchar();
printf(“%c”,a”);
a6  (+, H IM %'
:getche() 
getchar()0 ZT' !+ , @ *   !D/, H, H IM $T&'
) , * Q * I8QEnter cS * g6` * t ' !8 *)
conio.h() #  M
char a;
a=getche();
printf(“%c”,a”);
:getch() 
* g6` * t ' *:, @ * !D/ E:, H, H  # $T&'
conio.h #  M ) *:, * Q * I8Q EntercS
char a;
a=getch();
printf(“%c”,a”);
putcahar 
stdio.h *)  *:, @ * H, H  # $T&'
char a;
a=getch();
putchar(a);
a 6  *) 1FT    J#'
Control Statement %  ;3#

:0 &B * %&+'


:Selection 3M ;3# b1
  o z  ), ;3#  4 " , (3# ES+' 3M !) %/
if,if…else,switch ]
:loops ;3,b2
;  0  ;3#  4 " , (3# ES+' %/ !),
for,while.do….while ]
: Selection Staements 3M ;3#
:if (3# {1}
( *+ 3#M ) 0 o &H ]2
,
 \ ES+
: (34
if ( condition )
statement ;
Q) o@ z / % . 
  " ES8 ( condition ) o@ z ' . v+
/'  \ 0 ]2
{+: 12 . , !' * *. 8,  " vE: ES+'
 2  " M
*) { ~4,  "  4 " #B } ~4B _) 0 5 if J :ES+'
:*/
if ( condition )
{
statement 1 ;
statement 2 ;
}
:I] 2,
#include <stdio.h>
main()
{
float sum;
printf(“\n Enter the Sum : “);
scanf(“%f”,sum);
if (sum >50)
printf (“\n The student had passed”);
}
X 5,  U4 " 0 $T&  I& 3 '4#  J#/ K8# E: 9),
$4/
o@ z ' p) 50 (U4 "  A,"' 4:, ) c"+ 0 2 $F o@5 !83 5
J#/
}_\8  1
i / $T&  3 '4# 
(if ……. else statement ) R@ (3#
B
 U4 " 12 4  :   Iq 8\4 z5& K8# 8D8 4
500

0 `/ I K8# 0 ,. #3 14 /  1
9: Iq& E: * 5"
.H, o@ "&' 9, &# o@ (3# +T ++ }[4 H L p5
:9 K8# 9)  2 #2 (3# 0 =+,
#include <stdio.h>
Main()
{
float sum;
printf(“\n Enter the Sum : “);
scanf(“%f”,sum);
if (sum >50)
printf (“\n The student had passed”);
else
printf(“\n The student had failed”);
}
: (34
if ( condition)
statement-1;
else
statement-2;
o@ 4: ( condition ) 1
GH
. "+ (3# 9: Statement- 1
./# "+ (3# 9: Statement- 2
E :, -$T5 (3# R@   - ++ ' 0 T' 3 0 
0'` } 0,  4
'4#  
0 ]2
1+ `' /# "+ ,  "+ O82
9) vE:   t 8 *. L4H ;3# "+  05 04B 0 ~4B

};24# 4:,
 @5 _f4 
if ( condition)
{
statement 1;
statement 2;
statement n;
}
else
{
statement 1;
statement 2;
statement m;
}
/' 5 z5& K8# 4: 9 I] ,
,
c"+5 /' L . 0 K8# 0  X, };245 _# K-+ ;3#
+ ` [4
I i85 S' 3 ,
c"+ H 9) 1000 9  U4 "  3# 5 /4m  #&+
[&H 0 /
.3  /4m  #&+
;/ [&H i+ / K85  bo5 – X+ R B i8 +f) 4
U4 " *   
 , o,@ 0  !5 0 , `/
R (3# $T&8   vE: 9) }
0 h+
M R@ (3#  z/  ,
. K-+
if ( condition –1)
statement –1;
else if ( condition-2)
statement-2;
else if( condition-3)
statement-3;
………..
else
statement-n;
:I] 2,
:#H   K85
#include<stdio.h>
#include<conio.h>
Main()
{
Float num1,num2;
Char op;
Printf(“\n type num1,op,num2;
scanf(“%f%c%f”,&num1,&op,&num2);
if(op==’+’)
printf(“\n sum=%f”,num1+num2);
else if(op==’-‘)
prinf(“\n dub=%f”,num1-num2);
else if(op==’*’)
printf(“\n multi=%f”,num1*num2);
else if(op==’/’)
prinf(“\n div=%f”,num/num);
else
printf(“ERRoR”);
getch();}
  ~B K85
#include<stdio.h>
#include<conio.h>
Void main()
{ int dd/mm/yyyy,dd2/mm2/yyyy2;
Printf(“the year now:”);
Scanf(“%d”,& dd/mm/yyyy);
Printf(“the year you born:”);
Scanf(“%d”,& dd2/mm2/yyyy2);
Printf(“you have %d years!\n”, dd/mm/yyyy - dd2/mm2/yyyy);}
If(dd/mm==dd1/mm1)
Printf(“happy birthday to you”);
}

:switch (3#
;3#  4 " ES+' *) #&' M if….else 0 /5 14 ' 1 0 /
    * 3M  /, $TQ H  ; 4 "  0  0 +
:6 EM',switch (3# M 4\4 9#
switch (variable)
{
case value1;
statement 1;
break;
case value2;
statement 2;
break;
case value 3;
statement 3;
break;
……………
default:
statement;
}
3T 6 !/ (switch)   5
#/ -#   3T 1p) <8  2,
V4 / #2 {45 ~4B X 9/, }vES+' % VE 3T i B  ' VE,
0 {45 2 , H,  -# 0 3M ] / !+ 2 (67 ;245 iM
] ' 9, - 3T 6   5  4# (case)   5
#/ -# ;245
."+ (3# 9'' X 5, - o@
0 '4#  J+ 4:    vE: 0 =6, (break)  5 /# {45 %T/,
0:E 3#/, *4 :4 #/> (3# vE: ,#' B,  "+ (3# ES+'
;3# 5 ES+ '4#  J)/  ) ] I4 o@ z / %
: _ Iq
K-+

'4#  ' I -#  3T (3# 1
9: Iq& E: 0 5",
/!8 5, (break)  5 8& $F E }!) o V
z ' 5 ZB45
'4#  :ES+/ ;3#5 ,
(3#5  4# (default)  2 9'' -# ;245
.5& o,@ 0 V
z ' $ H 9)

(bb,++)1+, (/F 4


3 5  u+/ 1+  , H, 3 5   B /F/ (/F  1

(H,
: 6
H, 3 5 1+ 
H, 3 5 (/F ++ 
:for3#
,
) 0 
3  for   $T&'  * t ' < /H (3# *:
D8 ) 
7+ Gk 9.   t ', ;  0  ( 4 0  4 "
: (9  @
for ( counter statement; condition; step)
:1 GH
3  ;  "&' 9:  Sh, ( counter ) b
 -B 3  D/ . 3  /!8  / VE o@, (condition) o@b
.o@ 9S+/ *H
.3  ;   ' 9   9:, (step)gT -3 b
:,
for(exp1;exp2;exp3)
1  R 3   &/, (#2 , &5) :5 (3# I, 3 5 for $4',
_ 7 (exp2,(condition))
forz  $T5 i) + B "85 _f4/ 9  @,
#include <stdio.h>
main()
{
int counter;
for ( counter=1;counter<=20;counter++)
printf(“%d”,counter);
}
 !+5 045  4# ( for ) % 5 ;
5 for   1
"8 z5& K8# 0,b
(3# R4+  7S Q !+5 S' ;3# kQk
(3#,  9) -5   1FT' 94 b
20V,&' ,
0 B
  B 1
o@ +:, o@ 9: 8] b
1 3 5  F/ K8# E: 9), }(4T  ' 9!) ]] (3# 
b
.  !) ES+' ( 2
2*. 1 0 $B  #R i+ K+/ z5& K8#,b
:DHQ
}R4+  7S5 !`5 0 S' 1
"/ for   84  kQ] ;3#b
for   /5 9' 9 (3# I# %/ 
0 ]2
3 ' H 9)b
(3# 9: z5& I] )
printf ( " %d",counter;)
: nested for M for
:  @ EM', ]2 , (3, * !M5  @' (#2 (3, 0 ( 3#
For(exp1;exp2;exp3)
For(exp1;exp2;exp3)
For(exp1;exp2;exp3)
1-12 0 [` I,M EM8 I] 2,
#include<stdio.h>
main()
{ int i,j;
for(i=1;i<13;i++)
for(j=i;j<13;j++)
for(“%d*%d=%d”I,j,i*j);
}
:)while ) while loop 
ZB4/, ;  0 $4 stm ;3#  4 " , (3# 3  $T&'
while (3# *) 4\4 o * 3 
" 6
While(exp)
Stm;
*. 1 0   # while   $T _f4/ 9  @5 _f4  I] ,
:2
#include <stdio.h>
main()
{
int counter=1;
while ( counter <=20 )
{
printf(“%d”,counter);
counter++;
}
}
:  0  K'+ uT ++ / z5& I]  0
  t3M %'  -#   uT'
  M %'  (/A
:do…..while /3   
while ] 0 o@ Y), ( 1 ]2 ;3# 0  4 ", o 3  $T&'
: 6
do
{
statement 1;
statement 2;
.
.
statement n;
}
while ( condition
:3 ' [4  ;3# ES+' !8
do-while/3    * D  %:
,
z  > o@ 12 4, *H  * (H, (
0  9)  2 i#B C, ES+ 5 %/ o@ 0 z  1
X &S',
05&
_ 7 exp 1  R stm 3 ' %/
#2 , &5 stm 14 ' 1 0 /
:while&do….while 05 P6
%k , (3# ES+' do..whi.le 0 , (3# ES+' %k , o@ #T' while 1
o@ #T'
(H, ( (3# ES+' B * !8 <
:I] 2,
# include<stdio.h>
# include<conio.h>
main( )
{
char pass[10];
do
{
printf(“\n enter password: “ );
scanf(“%s”,pass);
}
while(strcmp(pass,”dahe”)!=0);
}
:;DHQ
5  L+k
!D' 4 &  2 +:
12 p) string )H (3# U48 0 0/6 i83 5 $4' : strcmp( )
S7  !+5 PS 12 05 0/6 
:-&  2 K8# /'
:(@ * $T&  ‫ ه‬/ * &  2 3,‫ ه‬$ )
# include<stdio.h>
# include<conio.h>
main( )
{
chat ch;
char pass[10];
do
{
textcolor(WHITE);
textbackground(BLUE);
cprintf(“\n enter password: “ );
textbackgrounf(WHITE);
cscanf(“%s”,pass);
}
while(strcmp(pass,”dahe”)!=0);
}
FUNCTION I,
i5 :‚  %/ % ! uT/, (   ! V4/ 9 ) K85 0 (3# 
 MMAIN  4 " * 9& 6 #  V4 ' <M  V M ,
]  I, 0printf,scanf,getchar) > 7M  L+5 0 /  2
.6 #  9) ()4

#include<filename.h>
Finclion declarations;…………………….(1)
Main()
{
Statements;
Function calling;………………………..(2)
Statements;
}
Function definition()…………………….(3)
{
Statements
}
V+  K8#  :' 9 (int,float….)  U48:type argument
,  B  '  B value  #  4# reurn (A4"     $T5
. void (    U48 14 /

ldentifiers ;)   &' o,@5 /,  % : function name

9 arguments g-4  -B 9:,:type arggument1,type argument2


0   ;  ;4  I#5 _ &' 9 ;6  U48,   '
 * <+  K8#
%\  3#M , 1Q  4:, function deelaration  0 1Q  9& 5 -1
 4\45

( $T) 5 I' , function calling  L  -2

%/ !QM 0 ;  / ' i) %/, funetion definition  Z/' -3
  =6 /'

:0 48 * %&+' *& 6 *) I,,


, printf()  ]  I, *:, Built in Function:6 I,b
!T K# < J&/  I, *:,scanf()
: ( #  $T&  I,b
K#  Jf, 0 * I, *:,
Jf4 *) ( 0 ]2 ,N 34 0  4 " 3 ' + i8 : !+ !,
34& vE: 52 %/ XE, . S+ ; 14 ' 0 3  ,
1p) ST
*N K8# 0 S+
:I, $T /F
%/ %k (H, ,  L@8. %/ GH : K8# M ;  3 ' $ -
!. \  + ( 0 ]2
!- 
YH4f, ]2
K8# _#/ I, $T5 -
:0 0  14 '
 %&\ b2  0 1Q W b1
# include <stdio.h>
#include<conio.h>
void line2(void);
main( )
{
clrscr( )
line2( )
printf(“ ** Allah the god of all world ** \n “);
line2( )
/* end of main( ) function */
}
void line2(void)
{
int j;
for(j=0;j<=40;j++);
printf( “ * “);
printf(“\n “);
}
: Jf4 kQk *) ;!h B, line2() %5  8@8
z5& K8# *)
#B X 14 / function declaration  0 1Q N * &/ : I,N Jf4 
/!8 *) R4+  7S yHQ8, ٣ %B3 & *)  2 main( ) &- 
.1Q
i8N LF"
M 1  <
*) !D/,main() &-  M : *8 G U =4 
) @5 14 /,  L  <
function coling * &/, &- 
12 ., U48 1,5 g)  % 52 %/ i), ٩ ,٧ & *)  2line2(
.;Q   8 ;Q !
* &/ LF" E:,main()&-  L!8 5  / :G] U =4 
*)
#', .  ;/4  52 %/ i), function definition  Z/'
52
#8, K85 !82, } ~45 %k  %5 ١١ %B3 & 0 K8#
}~45 *!+8 %k ~4 5  ; '

:Function Type I, U48


int function   7  B ' I,
float function H  B ' I,
string function )H (3# ' I,
void function  B < '  I,
struct function structure U48 0  B ' I,
# include <stdion.h>
int sum(int a, int b ) 1Q  0 
main( )
{
int z , x = 10 , y = 40;
z = sum(x,y);
printf(“\n\n z = %d “ , z );
}
/*  */
int sum(int a , int b )
{
C ;f  *) 6
%B3  S ٢٧
int s;
s=a+b;
return s;
}
** ;DHQ * K8# **
:U48 *:,
*:, int   5 O#, sum( ) %5  0 1Q  %' ٢ %B3 & *) -
 :, ~4BN 05 0/6 4\, DHQ J void  2 5', I, U48
 ;Q
1T&/, x ,y ;6  !4B
05,  L  %/ ٦ %B3 & *) -
)(34 vE!5 !+ +
+8N  ;Q 52 0 5(  ;Q 2
:!&S8   \ * ١٤ * ٩ 0 34&  @' -
١٠   *:, x6  *) (4\4   5 a6  0 =48 ٩ %B3 &
40 *:,. y6  *) (4\4   5 b 6  0 =48 XE2.
6 *) "+ J`8, b 6 , a 6  0 Q2 ;/4  J "8 ١٢ %B3 &
s 4: /\
$T5  L  1  * s 6  ;/4  (  8 ١٣ %B3 &
return  2
z = s  " I' ٦ %B3 &5 (4\4  z = sum(x,y)  \ 1 %!S8
* ZB4/  U48 1
I4' * (  0 _`/  *+ : : DHQ
. 0 "'   
int  U48 12 int "'    O82 p)
float  U48 12 float "'    O82 .,
U48 0 14 ) (return  \ *  @'  ) B '  *  

void
: L 
;Q 1,5 , ;Q 5  I, L  %/ -
52 $ < void line2(void)  ] ;Q 1,5  14 ' -
 ~4B
05 %B
:;Q 5  L  S2 _f4/ K85 -
# include < stdio.h>
# include <conio.h>
void line3(int no)
main( )
{
clrscr( )
line3(30);
printf(“ ** Allah the god of all world ** \n “);
line3(70);
}
void line3(int no)
{
int j , no;
for(j = 0 ; j <= no ; j++ )
printf(“ * “ );
printf(“\n”);
}
%/ ( 2 *), no4:, _ 7 U48 0 H,  ! +:  : DHQ
. L  + X,   ST  B I3
:;n6 5  L 
i&S8 K8#5 (4\4 5k %B U48 0 ;Q 5  L  0 
0 , $T&  0 ! B #&' ;6 ;Q  vE: 14 ' 1 0 / `/
,
L . ( ( 2 *) ;6  QM, 6' H *) S/ E:, K8# M
)K8# J  *) 8,
: n 7 ;n 2 ƒQk 0 #2N n  /  K85
# include <stdio.h>
/* determine the largest of three integer quantities */
main( )
{
int a, b, c, d;
/* read the integer quantities */
printf(“\n a = “);
scanf( % d “ , &a );
printf(“\n b = “);
scanf( % d “ , &b );
printf(“\n c = “);
scanf( % d “ , &c );
/* calculate and display the maximum value */
d = maximum( a, b );
printf(“\n \n maximum = % d , maximum(c ,d ));
}
/* determine the larger of two integer quatities */
maximum(x ,y )
int x ,y;
{
int z;
z = (x >= y ) ? x | y;
return(z);
}
:: DHQ
GH|R@ $!S Q %  ,
0 f 0
3#M test (3# (x > = y )
ifIq 0 (3# 
Else 0 (3# |
>   O82 ., x   EM/   7 (x >= y ) 3#M 12 . *+ 5
y  EM/   7
Reference Search G # J\

:
c &c++I 65 "# [2b1
C 65 "# 9) b2
;8, , [4  $4 @ &b3
/# /,b4
c6 *  b5
c 65 "# *) b6
c-in7-daysb7
The C Programming Languageb8

Vous aimerez peut-être aussi