Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

簡単電卓

#include <stdio.h>

int main(void)
{
    int a,b,ans;
    char ch;
    scanf("%d",&a);
    scanf("%c",&ch);
    scanf("%d",&b);
    if(ch == '+'){
        ans = a + b;
        printf("%d %c %d = %d",a,ch,b,ans);
    }else if(ch == '-'){
        ans = a - b;
        printf("%d %c %d = %d",a,ch,b,ans);
    }else if(ch == '*'){
        ans = a * b;
        printf("%d %c %d = %d",a,ch,b,ans);
    }else if(ch == '/'){
        ans = a / b;
        printf("%d %c %d = %d",a,ch,b,ans);
    }else{
        printf("もう一度入力してください");
    }
    return 0 ;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.