// Program to create a simple calculator#include<stdio.h>intmain(){charoperation;doublen1, n2;printf("Enter an operator (+, -, *, /): ");scanf("%c", &operation);printf("Enter two operands: ");scanf("%lf %lf",&n1, &n2);switch(operation) {case'+':printf("%.1lf + %.1lf...
Certification courses in Python, Java, SQL, HTML, CSS, JavaScript and DSA. Try Programiz PRO! Tutorials Examples Courses Try Programiz PRO C++ Examples Check Whether Number is Even or Odd Check Whether a character is Vowel or Consonant Find Largest Number Among Three Numbers Find All Roots...
// Program to build a simple calculator using switch Statement#include<iostream>usingnamespacestd;intmain(){charoper;floatnum1, num2;cout<<"Enter an operator (+, -, *, /): ";cin>> oper;cout<<"Enter two numbers: "<<endl;cin>> num1 >> num2;switch(oper) {case'+':cout<< num1...
Certification courses in Python, Java, SQL, HTML, CSS, JavaScript and DSA. Try Programiz PRO! Tutorials Examples Courses Login to PRO Introduction Getting Started with C# Your First C# Program C# Comments C# Variables and (Primitive) Data Types C# Operators C# Basic Input and Output C# ...
The switch statement allows us to execute a block of code among many alternatives. In this tutorial, you will learn about the switch...case statement in Java with the help of examples.