Soal Kasus Aritmatika (Pemr Dasar)
-
Upload
darmawansaputra -
Category
Documents
-
view
39 -
download
21
description
Transcript of Soal Kasus Aritmatika (Pemr Dasar)
![Page 1: Soal Kasus Aritmatika (Pemr Dasar)](https://reader036.fdokumen.com/reader036/viewer/2022082506/563dbb63550346aa9aacc095/html5/thumbnails/1.jpg)
TUGAS PEMROGRAMAN DASAR (ARITMATIKA)Darmawan Saputra ( XI RPL )
Soal 1Kode Program :
#include <iostream>using namespace std;
main() {int apelAlfan, jerukAlfan, apelBobby, jerukBobby, apelCitra, jerukCitra;double tempApelCitra, tempJerukCitra;
cout<<"---APP GAUL APEL JERUK GAUL---\n\n"<<endl;
cout<<"Masukkan jumlah apel Alfan : ";cin>>apelAlfan;
cout<<"Masukkan jumlah jeruk Alfan : ";cin>>jerukAlfan;
cout<<"Masukkan jumlah apel Bobby : ";cin>>apelBobby;
cout<<"Masukkan jumlah jeruk Bobby : ";cin>>jerukBobby;
cout<<"Masukkan berapa kali apel citra lebih banyak dari alfan : ";cin>>tempApelCitra;
cout<<"Masukkan berapa kali jeruk citra lebih sedikit dari bobby : ";cin>>tempJerukCitra;
apelCitra = tempApelCitra * apelAlfan;jerukCitra = jerukBobby / tempJerukCitra;
cout<<"\n\nTOTAL : "<<endl;cout<<"Jumlah apel citra = "<<apelCitra<<endl;cout<<"Jumlah jeruk citra = "<<jerukCitra<<endl;
}Hasil :
![Page 2: Soal Kasus Aritmatika (Pemr Dasar)](https://reader036.fdokumen.com/reader036/viewer/2022082506/563dbb63550346aa9aacc095/html5/thumbnails/2.jpg)
Soal 2:Kode :
#include <iostream>using namespace std;
main() {int angkaLama, angkaBaru, currentAngka, n;
cout<<"--- APP FIBONACCI --- \n"<<endl;
cout<<"Masukkan jumlah fibonaccinya : ";cin>>n;
cout<<"1, ";
for(int i = 1; i < n; i++) {if(i == 1) {
angkaLama = 0;angkaBaru = 1;
}else {
angkaLama = angkaBaru;angkaBaru = currentAngka;
}
![Page 3: Soal Kasus Aritmatika (Pemr Dasar)](https://reader036.fdokumen.com/reader036/viewer/2022082506/563dbb63550346aa9aacc095/html5/thumbnails/3.jpg)
currentAngka = angkaLama + angkaBaru;
if(i == n - 1) {cout<<currentAngka;
}else {
cout<<currentAngka<<", ";}
}}
Hasil :