0% found this document useful (0 votes)
3 views2 pages

Auto Cad 15

Auto cad week 1 ...............

Uploaded by

G KAMAL VARDHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Auto Cad 15

Auto cad week 1 ...............

Uploaded by

G KAMAL VARDHAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 2
Exp. Name: Write a C program to make a simple Calculator to Add, Subtract, Multiply or Divide using switch-case eee S.No: 20 Aim: Write a program to read two integer values and an arithmetic operator, depending on the operator perform different arithmetic operations. If integer values 2 and 3 are given with operator +, then the output should be 2 +3 = 5. If integer values 6 and 3 are given with operator /, then the output should be 6 / 3 = 2. Ifother than arithmetic operator is given, then display "Error! Operator is not correct” Note: Space before %c removes any white space (bianks, tabs, or newlines). It means %c without space wil read white space like new line(\n), spaces’) or tabs(\t). By adding space before %o, we are skipping this and reading only the char given. Instruction: To run your custom test cases strictly map your input and output layout with the visible test cases, Source Cod: (een | #includecstdio.h> void main() i int a,b; char op; printf("Values: *); scant ("%d¥d" ,&a,&b) 5 printf("Operator: "); scanf(" %c",8op); switch (op) { case break; break; break; case '/": if(bl=0) printf("%d / d = %d\n",a,b,a/b); else printf("Division is not possible! Divide by zero error\n"); breaks case ‘X" if(b!=0) printf('%d %% %d = Xd\n",2,b,aXb); else printf ("Modul division is not possible! Divide by zero error\n"); break; 4 'iprintf("%d + Xd = %d\n",a,b, a+b); Xd\n",a,b,a-b); mint # ("kd - Xd printf("Kd * %d %d\n"a,b,a*) 5 default: printf("Invalid operator\n"); ID: 2233140323, Page No: 1 (2022-2026 MECH-A| MVGR College of Engineering (Autonomous) Execution Results - Al test cases have succeeded! Test Case - 1 User Output jalues: 6 9 perator: — —— Test Case -2 User Output jalues: 6 9 perator: * bro = 54 Test Case - 3 User Output jalues: 8 9 jperator: @ Invalid Operator Test Case - 4 User Output jalues: 12 @ perator: / Division is not possible! Divide by zero error Test Case -5 User Output jalues: 5 jperator: % jodulo division is not possible! Divide by zero error Page No: 2 ID: 223310329 | (2022-2026 MECH-A| MVGR College of Engineering (Autonomous)

You might also like