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
This is a project specifically made for shirohime. Skills required: .NET, Fashion Design, Virtual Assistant

What is the use of a .disco file? A client application uses a .disco file to locate or discover the documents that have the description of a Web service. The .disco file having

Question 1 Discuss the following with respect to .NET Technologies Web Applications Web Server Connections Question 2 Write a sample program using ASP.NET explain

Explain the diffrent type of literals in c# The different types of literals in C# are: Boolean literals - Refers to the True and False literals that map to the true and fals

What is the difference between DELETE TABLE and TRUNCATE TABLE commands? Following are differences between delete & truncate commands:- 1)The DELETE TABLE syntax logs the de

How can we know a state of a thread? The "ThreadState" property is used to get complete detail of a thread. The Thread can have one or a combination of status.System.Threading.

Demonstrating use of break, continue & goto - C# Program How can i use break, continue & goto in my assignment, I am looking for a program in C#. It would be feel great if any

What is an object? They are instance of classes. It is a basic unit of a system. An object is an entity that has attributes, behavior, and identity. Attributes and behavior of

What is the difference between delegate and events? Actually events use delegates in the bottom. But they also add an extra layer on the delegates, hence forming the publisher

Jquery and MVC 4.5 Training Session I am looking who have industry experience working on Microsoft Technology ( MVC 4.5 ) and Jquery, who will take live online session and provi