Wednesday 1 December 2010

Write a function BatsmanAvg which calculate the average of a player (Batsman), Call this function in main program (Function). Take the input of Total Runs made and Total number of matches played from the user in main function.

#include <iostream.h> // allows program to output data to the screen
// function main begins program execution
int BatsmanAvg(int TotalRuns, int TotalMatches) ;
main()
{
int stopit;
int TotalRuns, TotalMatchesPlayed =0;
cout << "Please Entere the total Runs made : " ;
cin>> TotalRuns ;
cout << "Please Entere the total match played : " ;
cin>> TotalMatchesPlayed ;
cout << "\n Avg Runs = " << BatsmanAvg(TotalRuns,TotalMatchesPlayed);
cin>> stopit; //pause screen to show output

}
int BatsmanAvg(int TotalRuns, int TotalMatches)
{
return TotalRuns/TotalMatches; 
}

1 comment: