Thursday, 23 March 2023

Two-Number Addition Program

Here's an example program in C# for adding two numbers:

mohit

using System; 
class Program 

static void Main() 

Console.WriteLine("Enter the first number: "); 
int num1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Enter the second number: "); 
int num2 = Convert.ToInt32(Console.ReadLine()); 
int sum = num1 + num2; Console.WriteLine("The sum of {0} and {1} is {2}", num1, num2, sum); 
 } 
}

This program prompts the user to enter two integers, then adds them together and displays the result

No comments:

Post a Comment

Draw Circle in C#

 Here's an example program in C# that uses the `System.Drawing` namespace to draw a circle on a Windows Form: // Mohit Kumar Tyagi using...