PDA

View Full Version : CLASS 1: How To Add Two Integers Using C# In Visual Studio


Morash
03-21-2014, 12:15 AM
The Motive Of This Tutorial Is Just To Learn How To Type C# Code Using Visual Studio, How To Debug(Compile) And Run It.
This Is A Simple C# Program Which Is About Adding Two Integers Type Values. We Take Input Values From The User And Display It On The Screen. Follow Below;




Open Microsoft Visual Studio 2013

http://i58.tinypic.com/2mnhcfa.jpg






Create A New Project - Shortcut Key CTRL+SHIFT+N

http://i62.tinypic.com/xg0byd.jpg







Click On Visual C# And Select Console Application

http://i62.tinypic.com/291cgsi.jpg







Default Class, Function & Library Files Come Itself When A Project Is Created

http://i57.tinypic.com/ngodbs.jpg







Code For Adding Two Integers From The User Inside Main

http://i59.tinypic.com/1219zkw.jpg

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleAddition
{
class Program
{
static void Main(string[] args)
{
int first, second, result;
Console.Write("\nEnter First Value : ");
first = int.Parse(Console.ReadLine());
Console.Write("\nEnter Second Value : ");
second = int.Parse(Console.ReadLine());
result = first + second;
Console.WriteLine("\n\t "+first);
Console.WriteLine("\t+ " + second);
Console.WriteLine("\t------");
Console.WriteLine("\t " + result);

Console.ReadKey();
}
}
}







Click Debug & Select Start Debugging To Compile & Execute The Code

http://i61.tinypic.com/244ph08.jpg







Enter Two Values To Add

http://i59.tinypic.com/t5hdnd.jpg






Output

http://i59.tinypic.com/204gug.jpg

QUEEN OF HEARTS ...
03-21-2014, 12:36 AM
Thanks for sharin ..

AYAZ
03-21-2014, 01:00 AM
WOw thanks bro for such a wonderful tutorial. I came to know a lot from this. Will definately try.

nehastar1
03-21-2014, 09:07 AM
thanks for sharing

Morash
03-22-2014, 01:20 AM
Thank You All ..

AYAZ
03-24-2014, 06:46 PM
Thank You All ..

Morash , parse ki command input leney ka kaam karti hei ais mei? like jesyy simple C language mei scanf input leney ka kaam karti hie from user?

Princess Urwa
03-24-2014, 09:57 PM
thanks for sharing

Morash
03-25-2014, 12:03 AM
Morash , parse ki command input leney ka kaam karti hei ais mei? like jesyy simple C language mei scanf input leney ka kaam karti hie from user?

int.Parse Ki Command Hum String Type Variable Ko Int Mai Convert Karne K Liye Use Karte Hai ..
Aur User Se Input Lene K Liye Hum Console.ReadLine() Use Karte Hai ..

Copyright ©2008
Powered by vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.