Created
February 15, 2012 14:45
-
-
Save ChrisMoney/957e5d0d7640886cc6f3 to your computer and use it in GitHub Desktop.
C# --Passing functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C# Program: | |
//Passing functions | |
// AverageAndDisplay | |
using System; | |
namespace Example | |
{ | |
public class Program | |
{ | |
// access the member function | |
AverageAndDisplay(“grade 1”, 3.5, “grade 2”, 4.0); | |
// wait for user to acknowledge | |
Console.WriteLine(“Press Enter to ternminate…”); | |
Console.Read(); | |
// AverageAndDisplay – average two numbers with their labels and display the results | |
public static void AverageAndDisplay(string s1, double d1, string s2, double d2) | |
{ | |
double dAverage = (d1 + d2) / 2; | |
Console.WriteLine(The average of “ + s1 + whose value” + d1 + “and” + s2 + “whose value is” + d2 + “is” + dAverage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment