You are on page 1of 4

Praktikum Pemrogaman

Pertemuan 6
Nama
NPM
Kelas

: Andre Juniar
: 15312615
: TI 15 E

DoWhile
Sorcecode :
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace doWhile
{
class Program
{
static void Main(string[] args)
{
int a = 10;
do
{
Console.WriteLine("Nilai Variabel a " + a);
a = a + 1;
}
while (a < 20);
Console.ReadLine();
}
}
}

Output :

Neested_For_Loops
Sourcecode :

using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace neested_for_loops
{
class Program
{
static void Main(string[] args)
{
/*pendefinisian variabel lokal */
int i=2, j;
while(i<100)
{
i++;
for (j = 2; j <= (i / j); j++)
if ((i % j) == 0) break; // jika bukan prima
if (j > (i / j)) Console.WriteLine(i + " = Adalah Prima");
}
Console.ReadLine();
}
}
}

Output :

ConDown
Sourcecode :
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;

using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Balapan Karung Akan Dimulai.....");
int hitung = 10;
while (hitung > 0)
{
Console.WriteLine(hitung + "...");
hitung--;
}
Console.WriteLine("Mulai Brohhhhh!!!!!!!!!!!!!!!!!!!!!!!!!!!");
Console.ReadKey();
}
}
}

Output :

Menampilkan Bilangan Prima Menggunakan Nested Loop


Pseodecode :
using
using
using
using
using

System;
System.Collections.Generic;
System.Linq;
System.Text;
System.Threading.Tasks;

namespace neested_for_loops
{
class Program
{

static void Main(string[] args)


{
/*pendefinisian variabel lokal */
int i = 2, j;
for (i = 2; i < 100; i++ )
{
i++;
for (j = 2; j <= (i / j); j++)
if ((i % j) == 0) break; // jika bukan prima
if (j > (i / j)) Console.WriteLine(i + " = Adalah Prima");
}
Console.ReadLine();
}

Output :

You might also like