How to make a seperate function to print output in C#?

The name of the picture


How to make a seperate function to print output in C#?



I am learning function's in C# & decided to make a calculator. Here is the code I have written:-


using System;

namespace Second_Project
{
class Program
{
static void Main(string args)
{
Console.WriteLine("Entet any two numbers to find out its sum, product, difference, division & remaindern");
Console.WriteLine("Enter first number:-");
string input1 = Console.ReadLine();
Console.WriteLine("Enter second number:-");
string input2 = Console.ReadLine();
int num1 = int.Parse(input1);
int num2 = int.Parse(input2);
Calculation(num1,num2);
Console.Read();
}

private static void Calculation(float n, float m)
{
float sum, sub, mul, div, mod;
sum = n + m;
sub = n - m;
mul = n * m;
div = n / m;
mod = n % m;
Console.WriteLine("Sum of " + n + " & " + m + "=" + sum);
Console.WriteLine("Differnce of " + n + " & " + m + "=" + sub);
Console.WriteLine("Divission of " + n + " & " + m + "=" + div);
Console.WriteLine("Multiplication of " + n + " & " + m + "=" + mul);
Console.WriteLine("Remainder of " + n + " & " + m + "=" + mod);
}

}
}



But, I want to create different functions for calculations and printing & getting an error when I am trying to do that:-



Separate function for printing



Sorry, I know its a newbie question but I am still learning.



thanks in advance.









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Arduino Mega cannot recieve any sketches, stk500_recv() programmer is not responding

Visual Studio Code: How to configure includePath for better IntelliSense results

Future solutions