Monday, November 26, 2012

Array (One dimension and Multi dimension)

Modul_7  : Array
Nama      : Deab Sina
NIM        : 49012078
Jurusan    : D4 TMD ITB Batch 6

This is video about: Array (One dimension and Multi dimension) 


Link to this video:


Source code: 

===================================================
+ Array One dimension
===================================================

// Modul_7: Array
// Nama   : Deab Sina
// NIM    : 49012078
// Jurusan: D4 TMD ITB Batch 6

// one dimension array
#include <iostream>
using namespace std;

int main()
{
    // Declare int variable one dimension
    int arr1dimension[10];

    for (int x=0; x<10; x++)
    {
        cout<<"Please input value of element array number"<<x<<" : ";
        cin>>arr1dimension[x];
    }
    cout<<"The value taht you input is : "<<endl;
    for (int x=0; x<10; x++)
    {
        cout<<"Element number"<<x<<" = "<<arr1dimension[x]<<endl;
    }
    system("pause");
    return 0;
}
===================================================
+ Array Multi dimension
===================================================
// multi_dimension.cpp : Defines the entry point for the console application.
// Nama : Deab Sina
// NIM  : 49012078
// Jurusan : D4 TMD ITB Batch 6

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    // Declare char variable multi dimension
    char color[7][7] = {"Red","Blue", "Yellow", "Green","Orange", "Pink", "Purple"};

    for(int k=0; k<7; k++)
    {
        cout<<"Rainbow color is : "<<color[k]<<endl;
    }

    system("pause");
    return 0;
}


Show detail about this Modul.

Looping (while, do...while, for)

Modul_6  : Looping (Part 2)
Nama      : Deab Sina
NIM        : 49012078
Jurusan    : D4 TMD ITB Batch 6

This is video about:Looping


Link to this video:


Source code: 

===================================================
+ while loop:
===================================================

/*
Modul_6: LOOPING
Nama   : Deab Sina
NIM    : 49012078
Jurusan: D4 TMD ITB Batch 6
*/
#include <iostream>
using namespace std;

int main()
{
    // Local variable declaration
    int a = 10;

    // while loop execution
    while(a<20)
    {
        cout<<"D4 TMD ITB Batch 6 (Using while loop)"<<endl;
        a++;
    }
    system("pause");
    return 0;
}

===================================================
+ do...while loop:
===================================================

// do_while_loop.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
using namespace std;
// do...while loop
int _tmain(int argc, _TCHAR* argv[])
{
    //Local variable declaration
    int a = 10;

    //do loop excution
    do
    {
        cout<<"D4 TMD ITB Batch 6 (Using do...while loop)"<<endl;
        a = a + 1;
    }while(a < 20);
    system("pause");
    return 0;
}

===================================================
+ for loop:
===================================================

// for_loop.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include <iostream>
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    // for loop execution
    for (int a = 10; a < 20; a = a + 1)
    {
        cout<<"D4 TMD ITB Batch 6 (Using for loop)"<<endl;

    }
    system("pause");
    return 0;
}


Show detail about this Modul.