Posts

Showing posts with the label Switch case in C

C- Control Statement: Switch Codes

 1. Write a program to find the arithmetic operation using the switch statement #include <stdio.h> int main() {     float a, b, R;     char x;     printf("Enter the numbers: ");     scanf("%f%f", &a, &b);     printf("Enter the operation (+, -, *, /): ");     scanf(" %c", &x);          switch (x) {         case '+':             R = a + b;             printf("The sum is %.2f", R);             break;         case '-':             R = a - b;             printf("The difference is %.2f", R);             break;         case '*':             R = a * b;             printf("The product is %....