Lab7_Examplecode

Lab7_Examplecode - . Input : parameters a , b and c are all...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
1 C:\ali\pres\hes1300\2010\Lab Notes\lab6\week6-lab-example.c /* This program finds the average , the largest , the smallest and the median of the three integers read from the keyboard . Written by : Date : */ # include < stdio . h > /* Prototype declarations */ float myAverage ( int x , int y , int z ) ; int myMax ( int x , int y , int z ) ; int main () { int a , b , c , max ; float avg ; printf ( " Enter the first integer \ n " ) ; scanf ( "% d " a ) ; printf ( " Enter the second integer \ n " ) ; scanf ( "% d " b ) ; printf ( " Enter the third integer \ n " ) ; scanf ( "% d " c ) ; avg = myAverage ( a , b , c ) ; printf ( " The average of the given values is : % f \ n " , avg ) ; max = myMax ( a , b , c ) ; printf ( " The largest of the given values is : % d \ n " , max ) ; return ( 0 ) ; } /* This function adds all the inputs and returns the average
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: . Input : parameters a , b and c are all integers Output : average of a , b and c . The function returns a floating point value . */ float myAverage ( int x , int y , int z ) { float temp ; temp = ( x + y + z )/ 3 . ; return temp ; } /* This function returns the largest value . Input : parameters x , y and z are all integers Output : largest of x , y and z . The function returns an integer . */ int myMax ( int x , int y , int z ) { int temp ; if ( y > x ) { temp = y ; } else { temp = x ; } if ( temp > z ) { return temp ; } else { return z ; } }...
View Full Document

This note was uploaded on 09/29/2010 for the course C++ c taught by Professor Lauren during the Three '10 term at Swinburne.

Ask a homework question - tutors are online