Conversions    
 
  Constantes 
 
  Kepler's laws  
 
  Unités  
 
  ask us  
 


Coding &
programming


Installing CodeBlocs compiler

C language


C++ language




© The scientific sentence. 1998-2016 
 

Programming with C Language
Using sub program
Function max & min






Sub program: a funtion that
returs the max number


/*
Using here a sub program along with the main program
*/

#include <stdio.h>
// The sub program: a funtion that returs the max number
//------------------------------------------------------


float max (float x, float y)
{
if (x > y)
return x ;
else
return y ;
}

This function sets and returns the largest value between two real numbers x and y

// The main program:
//------------------


int main()
{
float number1, number2 ;

// Read the two flots

printf("Enter two floats \n -> ");
scanf ("%f%f", &number1, &number2);

// Display the two floats:

printf("The entered read numbers are: \n number1 = %5.3f, " "number 2 = %12.3f\n", number1, number2);

// Use the function max to display the maximum value:

printf("The max value is : %1.7f\n",
max (number1, number2));

// The used format reads and write the floats in wathever
// columns, but with two decimal digits
return 0;
}








  

Google
  Web ScientificSentence
 


chimie labs
|
scientific sentence
|
java
|
php
|
green cat
|
contact
|


© Scientificsentence 2009. All rights reserved.