You are on page 1of 5

TUGAS PENDAHULUAN MODUL 5

Nama : Duan Kelas : EE2

NIM : 102118062 Kelompok : 2

1.
#include <iostream>
using namespace std;
int main()
{ int a,b;
string NAMA;

cout<<"MASUKIN BATASAN : ";


cin>>a;
cout<<"Masukkan nama : ";
cin>>NAMA;
cout<<"Huruf Depan Nama Anda adalah :
"<<NAMA[0]<<endl;
cout<<"Huruf Belakang Nama Anda adalah : "<<NAMA[a-
1];
}
2. #include<iostream>
using namespace std;

int main() {
string groceries[4];
groceries[0]="beras";
groceries[1]="ubi";
groceries[2]="jagung";
groceries[3]="daging";
cout<<"Daftar Barang Anda: "<<endl;
cout<<"1. "<<groceries[0]<<endl;
cout<<"2. "<<groceries[1]<<endl;
cout<<"3. "<<groceries[2]<<endl;
cout<<"4. "<<groceries[3]<<endl;

}
3. #include <iostream>
using namespace std;
int main()
{
string nama [3];
nama [0] = " reza ";
nama [1] = " aminah ";
nama [2] = " amin ";
string phone [3];
phone [0] = " 082288995544 ";
phone [1] = " 082211667788 ";
phone [2] = " 082277889910 " ;
string x;
int i=0;
cout<<" semua teman kamu : " << endl;
cout<< "1. " << nama [0] << endl;
cout<< "2. " << nama[1] << endl;
cout<< "3. " << nama[2] << endl;
cout<< endl;
cout<< " Enter a name to get their number : ";
cin>> x;
while (i<=2){
if (x==nama[i]){
cout<<" The number is : "<<phone[i];}
else{
cout<< "";}
i++;
}
return 0;
}
4.
#include <iostream>
using namespace std;
int main()
{
string nama [3];
nama [0] = " reza ";
nama [1] = " aminah ";
nama [2] = " amin ";
string phone [3];
phone [0] = " 082288995544 ";
phone [1] = " 082211667788 ";
phone [2] = " 082277889910 " ;
string x;
int y;
int i=0;
cout<<" All of your friends : " << endl;
cout<< "1. " << nama [0] << endl;
cout<< "2. " << nama[1] << endl;
cout<< "3. " << nama[2] << endl;
cout<< endl;
cout<< " Enter a name to get their number : ";
cin>> x;
while (i<=2){
if (x==nama[i]){
y=i; }
else{
cout<< "";}
i++;}
if(y!=10){
cout<<" The number is : "<<phone[y];}
else{cout<<"Nama tidak dikenal ";}

return 0;}
5.
#include <iostream>
using namespace std;
int main()
{
string flavours [1000];
string y;
int x;
int i=0;

cout<< " please list your order below : "<<endl;

while (x<1000){
if ( y!="DONE"){
cin>>y;}
else{
break;}
flavours[x]=y;
x++;}
x=0;
cout<<endl;
cout<<"pizza queue(Type of next to continue):
"<<endl;
while(x<1000){
cout<<flavours[x]<" ";
cin>>y;
}
if(y=="next"){
flavours[x]="";
x++;}
else{break;}
if(rasa[x]=="ok")
{
break;}}

You might also like