Anda di halaman 1dari 6

KONSEP PEMROGRAMAN KOMPUTER

TUGAS 4

Oleh :

I Gede Ferdi Pratama 1905541123

PROGRAM STUDI TEKNIK ELEKTRO

FAKULTAS TEKNIK

UNIVERSITAS UDAYANA
Buat Flowchart dan program c/c++dari soal berikut:

1. Hitung jarak tempuh, dengan kec v, dan waktu t (detik)! 

      S = v * t 

Start

Int
Jarak (s)
Kecepatan
(v)
Waktu (t)

Input
Jarak
tempuh

s=v*t

Hasil
Jarak
tempuh
(s)

End

DevC++

#include<iostream>

#include<conio.h>

using namespace std;

int main ()
{

int s, V, t;

cout<<"Mencari Jarak dari Kecepatan dan Waktu"<<endl;

cout<<"Input Kecepatan =";

cin>>V;

cout<<"Input Waktu =";

cin>>t;

cout<<"Maka sesuai dengan rumus [s=V*t}"<<endl;

cout<<"Output Jarak ="<<V*t;

return 0;

2. Perkalian 2 pecahan: 

     P1 = ¾ 

     P2 = 2/3 

     Hasil = (3 x 2) / (4 x 3) => 6/12 


START

Input P1 = ¾
Input P2 = 2/3

Hasil = P1 * P2

Print Hasil

END
DEV C++

#include<iostream>

using namespace std;

struct pecahan

int pb;

int py;

};

int main (int argc, char** argv)

pecahan P1,P2,P3;

cout<<"Masukkan Pb P1 = ";

cin >> P1.pb; //pembilang P1

cout<<"Masukkan Py P1 = ";

cin >> P1.py; //penyebut P1

cout<<"\t "<<P1.pb <<endl;

cout<<"\tP1 = -" <<endl;

cout<<"\t "<<P1.py <<endl;

cout<<"Masukkan Pb P2 = ";

cin >> P2.pb; //pembilang P2

cout<<"Masukkan Py P2 = ";

cin >> P2.py; //penyebut P2

cout<<"\t "<<P2.pb <<endl;


cout<<"\tP2 = -" <<endl;

cout<<"\t "<<P2.py <<endl;

P3.pb = P1.pb*P2.pb;

P3.py = P1.py*P2.py;

cout<< "\nHasil Perkalian P1 & P2"<<endl;

cout<< "\t "<<P3.pb <<endl;

cout<< "\tP3 = -" <<endl;

cout<< "\t "<<P3.py <<endl;

return 0;

Anda mungkin juga menyukai