Program C

Program Hitung Waktu Tempuh

#include <stdio>

#include <conio>

void main ()

{

float wkt,total,wktawal;

float jarak=20; int kec=20;

wktawal=1/(jarak/5);

printf (“======================================================\n”);

printf (“Jarak tempuh   : 20 km\n”);

printf (“Kecepatan awal : 20 km/jam\n”);

printf (“======================================================\n”);

printf (“Jarak yang masih harus ditempuh : %.0f km\n”,jarak);

printf (“Kecepatan                       : %d km/jam\n”,kec);

printf (“Waktu yang dibutuhkan           : %.2f jam\n”,wktawal);

printf (“______________________________________________________\n”);

total=0;

for (int a=1;a<4;a++)

{

jarak=jarak-5;

kec=kec-5;

wkt=1/(jarak/5);

total=total+wkt;

printf (“Jarak yang masih harus ditempuh : %.0f km\n”,jarak);

printf (“Kecepatan                       : %d km/jam\n”,kec);

printf (“Waktu yang dibutuhkan           : %.2f jam\n”,wkt);

printf (“______________________________________________________\n”);

}

total=total+wktawal;

printf (“Total Waktu yang dibutuhkan     : %.4f jam\n”,total);

printf (“\n======================================================”);

getch ();

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s