menu

Rabu, 27 Mei 2015

TUGAS C++ pembuatan program dengn C++

TUGAS C++
pembuatan program dengan C++

Buatlah program dengan menggunakan nested for
Jawab :
#include <iostream.h>
#include <iomanip.h>

int main()
{
int x,y;
                for (x=1;x<=5;x++)
                {
                for(y=1;y<=5;y++)
                {
                cout<<setw(4)<<x+y<<"";
                }
                cout<<"\n";
                }
                return 0;
}


OUTPUT

2.        Buatlah program dengan for bersarang, 


Jawab :
#include <iostream.h>
#include <iomanip.h>

int main()
{
                int x,y;
                for (x=1;x<=10;x++)
                {
                                for(y=1;y<=x;y++)
                                {
                                cout<<setw(4)<<(x*2)+y<<"";
                                }
                cout<<"\n";
                }
                return 0;
}


 OUTPUT








Tidak ada komentar:

Posting Komentar