0% found this document useful (0 votes)
39 views5 pages

Nama 2

The document contains 5 programming assignments or tasks. Each task contains C++ code to solve different programming problems like printing patterns, checking prime numbers, simulating ball bouncing, and alternating patterns of hash symbols and letters.

Uploaded by

Maikhel G Harita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views5 pages

Nama 2

The document contains 5 programming assignments or tasks. Each task contains C++ code to solve different programming problems like printing patterns, checking prime numbers, simulating ball bouncing, and alternating patterns of hash symbols and letters.

Uploaded by

Maikhel G Harita
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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