Disini kita belajar menggunakan input tipe data String dan Float.
#include <stdio.h>
#include <stdlib.h>
char nama[30];
char jabatan[30];
float gapok,tanak,tistri,gatot;
int main(int argc, char *argv[])
{
printf("MENGHITUNG GAJI \n");
printf("=========================== \n");
printf("Nama : "); fflush(stdin);
gets(nama);
printf("Jabatan : "); fflush(stdin);
gets(jabatan);
printf("Gaji Pokok : ");
scanf("%f",&gapok);
printf("T. anak : ");
scanf("%f",&tanak);
printf("T. istri : ");
scanf("%f",&tistri);
gatot = gapok+tanak+tistri;
printf("------------------------------------------\n");
printf("Nama : %s \n",nama);
printf("Jabatan : %s \n",jabatan);
printf("Gaji Total : Rp. %.2f \n",gatot);
system("PAUSE");
return 0;
}
No comments:
Post a Comment