0% found this document useful (0 votes)
24 views1 page

Exp 11. Test Cases Design and Program Testing For The Simple Calculator Using Switch Case

This document describes an experiment to design test cases and test a simple calculator program using switch case statements in C. The program prompts the user to enter an operator and two operands, uses those values in a switch case to perform the calculation, and prints the result. It handles the four basic math operators and displays an error message for invalid operators.

Uploaded by

dharmveer singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

Exp 11. Test Cases Design and Program Testing For The Simple Calculator Using Switch Case

This document describes an experiment to design test cases and test a simple calculator program using switch case statements in C. The program prompts the user to enter an operator and two operands, uses those values in a switch case to perform the calculation, and prints the result. It handles the four basic math operators and displays an error message for invalid operators.

Uploaded by

dharmveer singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Exp 11. Test cases design and program testing for the simple calculator using switch case.

# include <stdio.h>
int main() {
char operator;
double firstNumber,secondNumber;
printf("Enter an operator (+, -, *,): ");
scanf("%c", &operator);
printf("Enter two operands: ");
scanf("%lf %lf",&firstNumber, &secondNumber);
switch(operator)
{
case '+':
printf("%.1lf + %.1lf = %.1lf",firstNumber, secondNumber, firstNumber +
secondNumber);
break;
case '-':
printf("%.1lf - %.1lf = %.1lf",firstNumber, secondNumber, firstNumber -
secondNumber);
break;
case '*':
printf("%.1lf * %.1lf = %.1lf",firstNumber, secondNumber, firstNumber *
secondNumber);
break;
case '/':
printf("%.1lf / %.1lf = %.1lf",firstNumber, secondNumber, firstNumber /
secondNumber);
break;
default:
printf("Error! operator is not correct");
}
return 0;
}

You might also like