Home > Uncategorized > While C++ part 2

While C++ part 2

Kali ini akan dimodifikasikan program table,cpp dengan menggunakan while statement. Dan jumlah baris dan kolom ditentukan oleh user

Berikut ini adalah contoh programnya

#include <iostream.h>

#include <iomanip.h>

void main()

{

int baris, kolom;

int i,j;

cout<< “Jumlah Baris :”;

cin >> baris;

cout<< “Jumlah Kolom :”;

cin >> kolom;

i=j=1;

while ( i<= baris){

while (j <= kolom){

long hasil = i*j;

j++;

cout <<setw(5)<<hasil<<“”;

}

i++;

j=1;

cout <<endl;

}

}

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: