Monday, November 26, 2012

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.


 

No comments:

Post a Comment