link

Jumat, 21 Juni 2013

program penjualan produk


#include "stdio.h"
#include "conio.h"

void main(){
    int i, kode[15], jumlah[15], jumdata=5;
    char*produk;
    float harga, total, disc, bayar;

    printf("\Input Data Penjualan");
    for(i=0;i<jumdata;i++){
        printf ("\nKode Produk :"); scanf("%d",&kode[i]);
        printf ("Jumlah Produk :"); scanf("%d",&jumlah[i]);
    }
    clrscr();
    printf ("\n                        Informasi Penjualan Produk");
    printf ("\n ---------------------------------------------------------------------------");
    printf ("\n No Kode Produk                  Harga  Jumlah   Total    Discount    Bayar");
    printf ("\n ---------------------------------------------------------------------------");
    for(i=0;i<jumdata; i++){
        if(kode[i]==1){
            produk = "TV"; harga = 2000000;
        }else if(kode[i]==2){
            produk = "DVD"; harga = 650000;
        }else if(kode[i]==3){
            produk = "CD ROOM"; harga = 450000;
        }
        total = harga*jumlah[i];
        if (total<2000000){
            disc=0.1*total;
        }else if (total<4000000){
            disc=0.15*total;
        }else if (total>4000000){
            disc=0.2*total;
        }else{
            disc=0;
        }
        bayar = total-disc;
        gotoxy(1,6+i); printf(" %i   %d   %s", i+1, kode[i], produk);
        gotoxy(30,6+i); printf("%10.0f   %i  %10.0f %10.0f%10.0f", harga, jumlah[i], total, disc, bayar);
    }
    printf("\n ---------------------------------------------------------------------------");
}

tampilan outputnya:

Minggu, 02 Juni 2013

Program perulangan

#include"stdio.h"
#include"conio.h"
void main()
{
          int i,masukkan,hasil=1;
          printf("Input Nilai : ");scanf("%d",&masukkan);
        printf("Hasil : ");
                  for(i=1;i<=masukkan;i++)
                        {
                            if(i==masukkan)
                                     printf("%d",i);
             else
                                                printf("%d*",i);

                                     hasil=hasil*i;
 }
                        printf(" = %d",hasil);


}