004 - 4 C C C

Info iconThis preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
4 C C C C : type-specifier function_name(parameter list) parameter declarations { body of the function } r e t u r n 4.1 C i n t : C 4.1.1 C C
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
[ 4 - 1 ] float sum( ); / * * / main ( ) { float first s e c o n d ; first =123.23 s e c o n d = 9 9 . 0 9 printf ("%f" sum (first s e c o n d ) ) } float sum (a b ) / * * / float a b { return a+b } sum( ) sum( ) : type_specifier function_name ( ) C 4.1.2 r e t u r n 1. } [ 4 - 2 ] pr_reverse () { char s[80] / * * / s c a n f ( " % s " s ) / * 7 9 * / p r i n t f ( " % s \ n " s ) } 5 8 C
Background image of page 2
return s1 s2 1 -1 [ 4 - 3 ] f i n d _ c h a r ( s 1 s 2 ) char s1 s 2 { i f ( s 1 = = s 2 ) return 1 e l s e return -1 } 2. A N S I C C C x = power (y) if (max (x y) >100) printf("greater") for (ch=getchar( ) isdigit (ch) ) . . . s w a p ( x y) =100 C sqr( ) sin( ) write( ) write( ) 1 A N S I C printf( ) mul( ) mul( ) int mul(int x, int y){. ..... } [ 4 - 4 ] main( ) { int x y z x = 1 0 y = 2 0 4 5 9
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
z = m u l ( x y ) /* 1 */ p r i n t f ( " % d " m u l ( x y ) ) /* 2 */ m u l ( x y ) /* 3 */ } mul( ) printf( ) 4.2 C g o t o C 4.2.1 C a u t o [ 4 - 5 ] f u n c 1 ( ) { int x; /* auto int x; */ x = 1 0 ; } f u n c 2 ( ) { int x; /* auto int x; */ x = - 1 9 9 9 ; x f u n c 1 ( ) f u n c 2 ( ) f u n c 1 ( ) f u n c 2 ( ) x x 6 0 C
Background image of page 4
a u t o a u t o a u t o [ 4 - 6 ] f ( ) { int t; s c a n f ( " % d " , & t ) ; i f ( t = = 1 ) { char s[80]; /* * / printf("enter name:"); g e t s ( s ) ; /* * / p r o c e s s ( s ) ; /* * / } } s i f s i f R A M 4.2.2 c o u n t m a i n ( ) [ 4 - 7 ] int count; /*count * / m a i n ( ) { count = 100; f u n c 1 ( ) ; } f u n c 1 ( ) 4 6 1
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
{ int temp; temp = count; f u n c 2 ( ) ; printf("count is %d",count); /* 100 */ } f u n c 2 ( ) { int count; for(count = 1; count < 10; count++) p u t c h a r ( ' . ' ) ; /* " " */ } c o u n t m a i n ( ) f u n c 1 ( ) f u n c 2 ( ) c o u n t f u n c 2 c o u n t c o u n t c o u n t C C m u l ( ) m u l ( x , y ) int x,y; int x,y; m u l ( ) { { r e t u r n ( x * y ) ; r e t u r n ( x * y ) ; } } x y x y 4.2.3 a u t o 6 2 C
Background image of page 6
auto int a, b, c; a u t o a u t o r e g i s t e r register int x, y, z; C P U C P U 4.2.4 s t a t i c static int a=8; [ 4 - 8 ] main( ) { inf f( ); /* * / int j; for (j=0; j<3; j++) printf ("%d\n" f( )) } int f( ) /* * / { static int x=1; x + + ; return x; } R U N 2 3 4 f( ) x f( ) x 1 4.3 4 6 3
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
4.3.1 4.3.2 call by value call by reference ( ) C 4 - 9 [ 4 - 9 main ( ) { int t =10 printf("%d %d " s
Background image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 21

004 - 4 C C C

This preview shows document pages 1 - 9. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online