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
Calculating the Sum of Digits - C# Program Hi, Can any of you, tell me how can i calculate the sum of digits of a given number?

I need Export Data using JSON Project Description: We could like to share our data with other websites via JSON. We are presently using Entity Framework with MySQL. We req

Project Description: I have various C# support projects and no time, so I'm seeking for a junior programmer to help out. This intro project is a C# module to develop the UI a

What is XML Text Reader? The "XmlTextReader" class helps to give fast access to streams of XML data in a forward-only and read-only manner. The XMLTextReader also checks if the

What is DAR (Decision Analysis and Resolution)? The Decision Analysis and Resolution is to analyze possible decisions using a formal evaluation process that identifies alternat

concept of strong names Strong name is similar to GUID(It is supposed to be unique in space and time) in the COM components.Strong Name is only needed when we need to deploy as

What are ASP.NET session and compare it with classic ASP session The ASP.NET session caches per user session state. It basically uses "HttpSessionState" class. The limitatio

Windows Phone 8 camera streaming to desktop app Project Description: I require WP8 application (client) that will: 1. Automatically evaluate and connect to Windows desktop

What is a candidate key? A table may have more than one combination of columns that could uniquely identify the rows in a table; every combination is a candidate key. During th

Project Description: We're seeking an IT candidate with experience to help us optimizely,  Skills required: .NET, C# Programming, ASP, eCommerce, SQL