C# CODING EXAMPLES: PROGRAMMING FOR BEGINNERS by KING J

C# CODING EXAMPLES: PROGRAMMING FOR BEGINNERS by KING J

Author:KING, J [KING, J]
Language: eng
Format: epub
Published: 2020-08-15T16:00:00+00:00


Find the addition of two integer numbers

Example:

Input:

First number: 10

Second number: 20

Output:

Addition of 10 and 20 is = 30

PROGRAM

using System;

class AddTwoNumbers {

static void Main() {

try{

//declare two variables

int a = 0;

int b = 0;

//input numbers

Console.Write("Enter first number: ");

a = Convert.ToInt32(Console.ReadLine());

Console.Write("Enter second number: ");

b = Convert.ToInt32(Console.ReadLine());

//calculating sum

int sum = a+b;

Console.WriteLine("Addition of " + a + " and " + b + " is = " + sum);

}

catch(Exception ex){

Console.WriteLine("Error: " + ex.ToString());

}

}

}

Output

Enter first number: 10

Enter second number: 20

Addition of 10 and 20 is = 30



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.