A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

C# | Find the addition of two integer numbers
Q:

C# | Find the addition of two integer numbers

0

Given (input) two integer numbers and we have to find the addition of given number in C#.

Example:

    Input:
    First number: 10
    Second number: 20

    Output:
    Addition of 10 and 20 is = 30

 

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now