C# Function which receives a float and an int from main(), finds the product of these two and returns the product which is printed through main().

/* C# Function which receives a float and an int from main(), finds the product of these two and returns 
   the product which is printed through main(). */
using System;
public class Demo
{
    public static float product(float i, int j)
    {
        float pr;
        pr = i * j;
        return pr;
    }

    public static void Main(string[] args)
    {
        float a, p;
        int b;
        Console.WriteLine("Enter Float Value :");
        a = float.Parse(Console.ReadLine());
        Console.WriteLine("\nEnter Integer Value :");
        b = Convert.ToInt32(Console.ReadLine());
        p = product(a, b);
        Console.WriteLine("\nThe product is {0}\n", p);
        Console.ReadLine();
    }
}

Output :
Enter Float Value :
2.5

Enter Integer Value :
2

The product is 5



Leave a comment