C Programming - Program Membuat Kalkulator Sederhana

| |
#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;
}

Related Posts by Categories

0 komentar:

Posting Komentar