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

How to make a Calculator

Calculator  - Visual Basic 2008 / 2010 Part- 1 This tutorial will show you how to make a basic calculator: Click on Project next to Create:  Click on Windows Form Application, and name the project "Your name's Calculator" and then click Ok. You can change the form text to "your name's calculator". Click on the form and then go to properties window, then change the text property. You also need to disable the maximize control of the form. That's because you don't want the user to maximize the calculator. Go to the properties window, and change the maximize box property to False:   You also need to change the FormBorderStyle property to Fixed3D   Add a button to the form and place on top of the form:   You might be surprised of this button because we should have placed a text box instead. Well, this is the cool thing about Visual Basic 2008, you can use a button to display text and results. Now we have to change the button prope...

Professional WordPress

Professional WordPress: Design and Development, 2nd Edition Brad Williams, David Damstra, Hal Stern     WordPress is the most popular self-hosted open source website software in use today, and the latest version makes it even simpler to operate. Packed with real-world examples for load balancing and multiusers, this esteemed resource replaces some of the more basic material with more advanced content. Every single chapter has been reworked to provide the most current and proper methods for developing and designing in WordPress. Coverage of HTML5, CSS3, and JavaScript and new chapters on custom post types, custom taxonomies, Multisite, and extensions of themes bring the content of this book completely up-to-date and provides you with all you need to deploy successful WordPress sites.      

Professional WordPress Design and Development, 3rd Edition

Professional WordPress: Design and Development, 3rd Edition Brad Williams, David Damstra, Hal Stern ISBN: 978-1-118-98724-7 504 pages December 2014 Professional WordPress is the only WordPress book targeted to developers, with advanced content that exploits the full functionality of the most popular CMS in the world. Fully updated to align with WordPress 4.1, this edition has updated examples with all new screenshots, and full exploration of additional tasks made possible by the latest tools and features. You will gain insight into real projects that currently use WordPress as an application framework, as well as the basic usage and functionality of the system from a developer's perspective. The book's key features include detailed information and real-world examples that illustrate the concepts and techniques at work, plus code downloads and examples accessible through the companion website. Written by practicing WordPress developers, the c...