Perform arithmetic operations - c# program, DOT NET Programming

Perform Arithmetic Operations - c# Program

Hello, i didn't find the correct way of using arithmetic operations in c#. I am beginner for this language. Please suggest me some examples.

Posted Date: 2/11/2013 6:28:49 AM | Location : United States





Hey this a very easy code for your problem try this.

Perform Arithmetic Operations

using System;  

class integerdemo {

  public static void Main()

 {  

   string s1,s2;

   int a,b;  

  Console.Write("Enter no 1 # "); // Display to enter no. 1

  s1 = Console.ReadLine ();           // save the number in a string variable s1

  a = int.Parse (s1);                      // the string s1 is converted into int type variable  

  Console.Write("Enter no 2 # "); //Display to enter no. 2

  s2 = Console.ReadLine ();        // save the number in a string variable s2

  b = int.Parse (s2);                     // the string s2 is converted into int type variable

   // Here er converted both the string variables to int because we wanted to do 

   // integer / numeric manipulation with the inputted string variables

   Console.WriteLine(""); // Blank line

  Console.WriteLine("*** Integer manipulations ***");

  Console.WriteLine(""); // Blank line

                                   // Integer manipulations

   Console.WriteLine("No1 + No2 = " + (a+b));

  Console.WriteLine("No1 - No2 = " + (a-b));

  Console.WriteLine("No1 / No2 = " + (a/b));

  Console.WriteLine("No1 * No2 = " + (a*b));

  Console.WriteLine("No1 % No2 = " + (a%b));

   Console.ReadLine();  

 }

}

Posted by | Posted Date: 2/11/2013 6:30:30 AM

Thanks it was very useful. I was?looking for this. Everything is ok and cleared.

Posted by Edward | Posted Date: 2/11/2013 6:32:27 AM


Related Discussions:- Perform arithmetic operations - c# program, Assignment Help, Ask Question on Perform arithmetic operations - c# program, Get Answer, Expert's Help, Perform arithmetic operations - c# program Discussions

Write discussion on Perform arithmetic operations - c# program
Your posts are moderated
Related Questions
Could you please explain to me the different types of DOT NET programming

What is Multi-tasking? It is a feature of the modern operating system with which we can run multiple programs at the same time for example Word, Excel etc.

Define the ToolTip control. How can you associate it with other controls? The ToolTip control produces a small pop-up window with explanatory text for an element it is displaye

Differentiate between managed and unmanaged code? Managed code is the code that is implemented directly by the CLR instead of the operating system. The code compiler first comp

What are indexes? The Indexes in the SQL Server are similar to the indexes in books. They help SQL Server to retrieve the data quickly.These are classified into clustered and n

What is MVC pattern? The main purpose  of using  the MVC pattern is to decouple the GUI from the Data. It also gives the ability to provide multiple views for the same Data. Th

What is .NET Remoting? The .NET remoting is replacement of DCOM. Using .NET remoting you can make remote object calls that lie on different Application Domains. since the remot

Develop .Net project Project Description: We want to make .net you have to be good knowledge on the subsequent Microsoft Active Directory, Lync 2010 - 2013 databases

What is object-oriented programming (OOP)? OOP is a method to develop logical modules, such as classes that contain properties, methods, fields, and events. An object is formed

What are Daemon threads? Daemon thread's run in the background and stop automatically when nothing is running program. The Example of a Daemon thread is the "Garbage collector"