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

Program: Using Using Using Using Namespace Class Static Void String Double Char

This document contains code for a C# console application that performs basic arithmetic operations. The application prompts the user to enter two numbers and an operator, performs the calculation based on the operator using a switch statement, and displays the result. It handles addition, subtraction, multiplication, division, and invalid operators.

Uploaded by

JhosepCayao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Program: Using Using Using Using Namespace Class Static Void String Double Char

This document contains code for a C# console application that performs basic arithmetic operations. The application prompts the user to enter two numbers and an operator, performs the calculation based on the operator using a switch statement, and displays the result. It handles addition, subtraction, multiplication, division, and invalid operators.

Uploaded by

JhosepCayao
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

using

using
using
using

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

namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
double n1, n2, resul = 0;
char op;
System.Console.WriteLine("ingrese el primer numero:");
n1 = Convert.ToInt32(Console.ReadLine());
System.Console.WriteLine("ingrese segundo numero:");
n2 = Convert.ToInt32(Console.ReadLine());
System.Console.WriteLine("ingrese operador");
op = Convert.ToChar(Console.ReadLine());
switch (op)
{ case '+': resul = n1 + n2;
break;
case'-': resul = n1 - n2;
break;
case '*': resul = n1*n2;
break;
case '/': resul= n1/n2;
break;
default:
System.Console.WriteLine("operador no valido");
break;
}
System.Console.WriteLine("resultado:" + resul);
Console.Read();
}
}

You might also like