Bahasa C – Tugas 25.4

Buatlah sebuah program yang menerima imputan 10 harga barang. Program tersebut akan menampilkan inputan harga barang dan jumlah total barang tersebut.

Okay …  :thumbup

main()
{
    int barang[10],loop,scanfloop,total=0;
    for (loop=1;loop<=10;loop++)
    {
        scanfloop=loop-1;
        printf("Masukkan harga barang %d : ",loop); scanf("%d",&barang[scanfloop]);
    }
    system("cls");
    for (loop=1;loop<=10;loop++)
    {
        total=total+barang[scanfloop];
        scanfloop=loop-1;
        printf("Harga barang %d adalah : %d \n",loop,barang[scanfloop]);
    }
    printf("\nTotal harga : %d",total);

    getch();
}

Share Button

By Rinaldo Jonathan

Admin of this site. Artis papan PCB. #zoneRinaldo #Controllerism Studio Demon, Stage Angel, Sleepy Developer, Smoke free. Kalkud SHS 2012, PCR G15.

Leave a Reply

Verified by ExactMetrics