Wednesday, July 13, 2011

C Programming - Program Menganalisa Sirkuit Sederhana

#include <stdio.h>

typedef double resistance;

int main()
{
    resistance R1, R2, R3;
    double TotalR, Voltase, Arus;
    /* Minta tiga resistan dan voltase */
    printf("berikan tiga resistan (ohm) :");
    scanf("%lf %lf %lf", &R1, &R2, &R3);
    printf("voltase yang digunakan (volt) :");
    scanf("%lf", &Voltase);

    /* Hitung total resistan dan arus */
    TotalR = 1.0 / (1.0 / R1 + 1.0 / R2 + 1.0 / R3);
    Arus = Voltase / TotalR;

    /* Tampilkan Arus */
    printf("Arusnya = %.2lf amps.\n", Arus);

    return 0;
}

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...