Skip to main content

Program_function_01

Using Function: Finding the maximum of three integers.

/* Fig. 5.4: fig05_04.c
    Finding the maximum of three integers */
 #include <stdio.h>
int maximum( int x, int y, int z ); /* function prototype */

 /* function main begins program execution */
 int main( void )
 {
    int number1; /* first integer */
    int number2; /* second integer */
    int number3; /* third integer */

    printf( "Enter three integers: " );
    scanf( "%d%d%d", &number1, &number2, &number3 );

    /* number1, number2 and number3 are arguments
       to the maximum function call */
    printf( "Maximum is: %d\n",  );
    return 0; /* indicates successful termination */
 } /* end main */

/* Function maximum definition */
/* x, y and z are parameters */
int maximum( int x, int y, int z )
{
   int max = x; /* assume x is largest */

   if ( y > max ) { /* if y is larger than max, assign y to max */
      max = y;
   } /* end if */

if ( z > max ) { /* if z is larger than max, assign z to max */
      max = z;

} /* end if */

   return max; /* max is largest value */
} /* end function maximum */
Output:


Comments

Popular posts from this blog

TSDA Class Schedule List

Taieba Soft & Digital Academy (TSDA) www.tbsbd.blogspot.com Web Design Class No. Subject:-->HTML 1 Introduction of HTML,Basic Stru.HTML Elements, Defines Tag, Attributes and Text 2 Heading,Paragraph,Line Breaks, HTML Formatting,head tag(meta,style,js,title) 3 HTML Links, HTML Images, HTML link underline,Marquee,Images Mapping,Area 4 HTML lists(ol,ul,li), Nested List, menu_list,directory_list,defination_list 5 Audio,Video, Youtube Video,Mailto link 6 Table,th,tr,thead,tbody,tfoot, colspan and rowspan,nested table 7 Normal form, form alignment,fieldset,legend  8 Frame,Iframe, entites, color code, DTD and seo(meta) DreamWaver CS5 9 Dreamwaver Installation,How To use,Doctype,HTML Format,Version and  clasiffication CSS(Cascading Style Sheet) 10 Syntax,Classification, ID &Class, How to use ID ...