Pages

Monday, November 3, 2014

IF pada C





Unknown | 9:33 AM | 0 Comments

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <iostream>

using namespace std;

int main()
{
char kb, nb;
int stuan, jb, tb, hb;
float th, pot,tot;
printf("--------------------------------------------------------------\n");
printf("\t \t MINI MARKET SERBA ADA \n");
    printf("--------------------------------------------------------------\n");
    //input
    printf("Kode Barang \t : ");scanf("%s",&kb);
    printf("Nama Barang \t : ");scanf("%s",&nb);
    printf("Satuan \t \t : ");scanf("%i",&stuan);fflush(stdin);
    printf("Jumlah Beli \t : ");scanf("%10.i",&jb);fflush(stdin);
    printf("Harga Beli \t : ");scanf("%i",&hb);fflush(stdin);
    printf("--------------------------------------------------------------\n");
   

    th = jb * (float)hb;

printf("Total Harga \t : Rp. %10.2f \n ",th);
if(th > 100000)
{
pot =0.1*th;
}
else
{
pot=0;
}
printf("Potongan \t : Rp. %10.2f \n ",pot);
printf("--------------------------------------------------------------\n");

tot = th-pot;
printf ("Total Bayar \t : Rp. %10.2f \n ",tot);
printf("--------------------------------------------------------------\n");
getch();
return 0;
}

Read more ...

Menghitung Luas & Kel Persegi Panjang dengan C





Unknown | 9:30 AM | 0 Comments

#include <stdlib.h>
#include <iostream>
#include <stdio.h>

using namespace std;

int main()
{
    float p,l,lu,kel;
    printf("--------------------------------------------------\n");
printf ("\t Menghitung Luas dan Keliling \n");
    printf ("\t \t Persegi Panjang \n");
    printf("--------------------------------------------------\n");
    //input
    printf("Masukan Panjang \t : ");scanf("%f",&p);
    printf("Masukan Lebar \t \t : ");scanf("%f,",&l);
    printf("--------------------------------------------------\n");

    //proses
    lu = p*l;
    kel = 2*(p+l);

    //output
    printf("Jadi \t \t \n");
    printf("Luasnya adalah \t \t : %10.2f \n",lu);
    printf("Kelilingnya adalah \t : %10.2f \n",kel);
    printf("--------------------------------------------------\n");

    system ("PAUSE");
    return 0;

}

Read more ...




Unknown | 9:15 AM | 0 Comments

Read more ...