0% found this document useful (0 votes)
29 views

C Sharp

The document describes a mini calculator program that reads two integer numbers from the keyboard, reads an operator (+, -, *, /) from the keyboard, performs the calculation on the numbers based on the operator, and displays the result. It uses a switch statement to perform the correct calculation based on the operator entered and checks for division by zero before performing that operation.

Uploaded by

Elena Bîrsan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

C Sharp

The document describes a mini calculator program that reads two integer numbers from the keyboard, reads an operator (+, -, *, /) from the keyboard, performs the calculation on the numbers based on the operator, and displays the result. It uses a switch statement to perform the correct calculation based on the operator entered and checks for division by zero before performing that operation.

Uploaded by

Elena Bîrsan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Sa se realizeze un mini-calculator care sa permita +,-,*,/, a doua nr intregi citite de la tastatura int a,b,rez=0

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

namespace ConsoleApplication129 { class Program { static void Main(string[] args) {int a, b, rez; char op; Console.Write("a="); a = int.Parse(Console.ReadLine()); Console.Write("b="); b= int.Parse(Console.ReadLine()); Console.Write("alegegeti una din operatiile +,-,*,/,:"); op = char.Parse(Console.ReadLine()); switch (op) { case '+': rez = a + b; break; case '-': rez = a - b; break; case '*': rez = a * b; break; case '/': if (b != 0) rez = a / b; ; else rez= 0; break; } Console.Write("{0}{1}{2}={3}",a,op,b,rez); Console.Read(); } } }

You might also like