Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

add two numbers in c#

using System;

namespace Add{
	public class Program{

		public static int addition(int a, int b){
			return (a+b);
		}

		public static void Main(){
			int a,b;
			int sum;

			Console.Write("Enter first number: ");
			a = Convert.ToInt32(Console.ReadLine());

			Console.Write("Enter second number: ");
			b = Convert.ToInt32(Console.ReadLine());

			sum = addition(a,b);

			Console.WriteLine("Sum is: " + sum);
		}
	}
}
Comment

add numbers c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Addition
{
    public class Program
    {
        public static void Main(string[] args)
        {
            int a;
            int b;
            int add;


            Console.WriteLine("Enter Your First Number: "); //allow user input
            a = int.Parse(Console.ReadLine()); //convert to answer (string) to int

            Console.WriteLine("Enter Your Second Number: ");
            b = int.Parse(Console.ReadLine());

            add = a + b; //add the input numbers

            Console.WriteLine(); //blank space
            Console.WriteLine(a + "+" + b + "=" + add); // Print the sum of a + b
            Console.WriteLine(); //blank space
        }
    }
}
Comment

add numbers c#

//c#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace Program
{
    public class Addition
    {
        public static void Main(string[] args)
        {
           int x = 5; //set value for x
           int y = 6; //set value for y
           int sum; 
            
           sum = x + y; //add the numbers
            
           Console.WriteLine(sum); // Print the sum of x + y
        }
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: windows 10 see how long a program has been running 
Csharp :: copy properties from two subclasses c# 
Csharp :: linq pick random element 
Csharp :: c# wait without GUI blocks 
Csharp :: C# today, yesterday, last week, last month 
Csharp :: commandline to open outlook minimized 
Csharp :: dotnet DB context register 
Csharp :: c# return default "" if null 
Csharp :: get image information using c# 
Csharp :: set main camera unity 
Csharp :: maximum sum of non-adjacent 
Csharp :: c# only only 2 digits after decimal number double 
Csharp :: c# loop array back 
Csharp :: c# get folder of full ilepath 
Csharp :: how to find min of an array in c# 
Csharp :: unity destroy gameobject with delay 
Csharp :: urp set postprocessing value 
Csharp :: how to dynamically load value in startup file in c# 
Csharp :: forces the user to enter his password before submitting the form asp.net core 
Html :: fevicon 
Html :: htaccess remove .html 
Html :: file input only images 
Html :: centralize div bootstrap 
Html :: python jupyter markdown color 
Html :: target blanc 
Html :: vscode user code snippet not working markdown 
Html :: bootstrap flexible card 
Html :: button center bootstrap 
Html :: make text vertical align middle in table bootstrap 
Html :: tailwind cdn v3 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =