C Programming - Program Membuat Kalkulator Sederhana

Thursday, July 14, 2011
#include <stdio.h>

int main()
{
    char op;
    int bil1, bil2;
    printf("Tuliskan bilangan, operator, bilangan :");
    scanf("%d %c %d", &bil1, &op, &bil2);

    switch(op)
    {
        case '+': printf("= %d", bil1 + bil2); break;
        case '-': printf("= %d", bil1 - bil2); break;
        case '*': printf("= %d", bil1 * bil2); break;
        case '/': printf("= %d", bil1 / bil2); break;
        default : printf("operator tidak dikenal!");
    }
    printf("\n\n");

    return 0;
}