Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Nama 2

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

Nama : Maikhel Gersom Harita

NIM : 121300002

Tugas 1

/*============= Pengantar Komputer & Software =============*/

#include <iostream>

using namespace std;

int main()
{
int m;

cout << "Input jumlah panjang pola : ";cin>>m;cout<<endl;

for(int i = 1; i<= m; i++){


for(int j = m; j >= i; j--){
cout << "*";
}
}

return 0;
}
Tugas 2
Tugas 3

/*============= Pengantar Komputer & Software =============*/

#include <iostream>
using namespace std;
int main()
{
int x, i, m=0, aw=0;

cout << "Bilangan prima atau bukan,cek\nInput angkanya


bang : ";
cin >> x;cout<<endl;
m=x/2;

for(i = 2; i <= m; i++)


{
if(x % i == 0)
{
cout << "Angka "<<x<<" bukan bilangan Prima"<<endl;
aw=1;
break;
}
}
if (aw==0)
cout << "Angka "<<x<<" adalah bilangan Prima"<<endl;
return 0;
}
Tugas 4

#include <iostream>

using namespace std;

int main()
{

float n = 0.3;
float g,t;

cout<<"input ketinggian bola : ";cin>>g;


cout<<endl;

while(g > 1){


g = g - (g*n);
g = g + 1;
g--;
t= t + g;
cout<<"Pantulan berikutnya : "<<g<<" cm";
cout<<endl;

}
cout<<"\n=========== Pantulan berakhir\n";
cout<<"\nPanjang Lintasan : "<<t<<" cm";
}
Tugas 5

#include <iostream>

using namespace std;

int main()
{
int n;

cout<<"Input angka : ";


cin>>n;

for(int i = 1; i<=n; i++){


if (i%2==0){
for(int j = 1;j <= n; j++){
(j%2==0) ?
cout << "#" : cout << "o";
}
}else{
for ( int k = 1; k <= n; k++){
(k%2==0) ? cout <<"o":cout<<"#";
}
} cout<<endl;
}
return 0;
}

You might also like