C# Adding 2+ numbers in a console application *beginners*

All tutorials created in C# to be posted in here.
4 posts Page 1 of 1
Contributors
User avatar
thekingajew
Just Registered
Just Registered
Posts: 3
Joined: Thu Oct 31, 2013 6:46 am

Just showing how to add 2 numbers together. Alot of you know this but when i started college i struggled to find answers to these kind of codes so i quickly put a small few line code together.

This can be easily modified and improved.

This can be a start towards making a ( - + * / ) calculator

What the code looks like

Image

How the code runs (This can be enhanced to run better)

Image

Get the code here, When using the code remove the comments "//"
Code: Select all
// Basic add 2 numbers together ...

            // Get number 1
            Console.Write("Please enter number 1 ... ");
            int number1 = int.Parse(Console.ReadLine());

            // Get number 2
            Console.WriteLine("please enter number 2 ... ");
            int number2 = int.Parse(Console.ReadLine());

            // Add number 1 and number 2
            int answer = number1 + number2;

            // Print answer to console 
            Console.WriteLine("the answer is: " + answer);

            // keep the console open until a key is pressed
            Console.WriteLine("press a key to continue ... ");
            Console.ReadKey();
If this is of any use please check out my website http://free4later.com/
If ive helped you why not help me? http://www.points2shop.com?ref=thekingajew
User avatar
XTechVB
VIP - Site Partner
VIP - Site Partner
Posts: 727
Joined: Thu May 20, 2010 10:32 am

Very basic, but a good start for who wants to learn C#
You can find me on Facebook or on Skype mihai_92b
User avatar
pip
VIP - Donator
VIP - Donator
Posts: 156
Joined: Tue Jul 12, 2011 3:13 am

Very good tutorial #thekingajew and i am glad you signed up it is me xpron3xgamer :) .
<a href="http://www.points2shop.com/s/xbox_point ... 5082"><img src="http://points2shop.com/images/promotion ... ricoxg.gif" border="0"/></a>
User avatar
thekingajew
Just Registered
Just Registered
Posts: 3
Joined: Thu Oct 31, 2013 6:46 am

Hi, Thanks for referring me to this site :) Its helped me and i hope i can help others :)
pip wrote:
Very good tutorial #thekingajew and i am glad you signed up it is me xpron3xgamer :) .
If ive helped you why not help me? http://www.points2shop.com?ref=thekingajew
4 posts Page 1 of 1
Return to “C-Sharp Tutorials”