Add two numbers and print the output

Create a C# console application to add two numbers. You need to create two variables and give them two numbers. Do not ask the numbers from the user. Add these two numbers and put the result in a third variable. Print the output in the following format

The sum of 5 and 10 is 15.

How to print the output

Normally you will be using Console.Write() function to print on the console window. In C# you can give the Console.Write() function a formatted string and provide the values which you wish to show in the string. For example look at the code below

Console.Write(“The sum of {0} and {1} is {2}”, a, b, c);

In the code above you are giving the Console.Write methods a formatted string with {0}, {1} and {2} as the placeholders. The Write function will replace the value of {0} with a, {1} with b and {2} with c and print the file output with replaced values.

Quick Links



Total Followers
Study Group Created
Study Group Joined
Following Teacher
Following Organization
Blog Articles Added
Questions Asked
Questions Answered
Jobs Posted
Total Members in Group
Questions asked by members
Tasks added in this Group

Please wait..


Login to Open ESchool OR Create your account    Login   SignUp