Saturday, March 25, 2023

add ,substact ,multiply ,divide two numbers using switch statement .

 //add ,substact ,multiply ,divide two numbers using switch statement

#include <stdio.h>
int main (){
    int a,b,ch,c ;
    printf ("enter two number  and ch\n");
    scanf ("%d%i%d",&a,&b,&ch);
   
    switch(ch){
        case 1:c=a+b;
        printf ("%d",c);
        break;
        case 2:c=a-b;
        printf ("%d",c);      
         break;
        case 3:c=a*b;
        printf ("%d",c);
        break;
        case 4:c=a/b;
        printf ("%d",c);
        break;

    }
    return 0;
}

No comments:

Post a Comment

print a multiplication table of any integer taking from user

 // print a multiplication table of any integer taking from user  #include "stdio.h" int main () { int n,mul,i; printf ("...