Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

5.

#include <iostream>

using namespace std;

int main()
{

int i, total, nilai;


total = 0;

for (int i = 0; nilai <= 500; i++)


{
cout << "Input Nilai = ";
cin >> nilai;

total = total + nilai;


}

cout << "Total Nilai = ";


cout << total;

return 0;
}

6.

d.
#include <iostream>

using namespace std;

int main()
{

int b, k, n = 5;

for (int b = 0; b < 3; b++)


{

for (k = 0; k < 5; k++)


{
cout << n;
cout << " ";
}
n = n + 5;
cout << "\n";
}

return 0;
}
e.
#include <iostream>

using namespace std;

int main()
{
int b, k, n = 1;
int jk = 5;

for (b = 1; b <= 5; b++)


{
for (k = 1; k <= jk; k++)
{
cout << n << " ";
}
n++;
jk--;
cout << endl;
}

return 0;
}

7.

a.
b.

You might also like