Nama : Reza Hidayatulloh
Nim : 3420210019
Prodi: Teknik Informatika
tugas 1
/*---------------------------*/
/* Program for - bilangan naik */
/*---------------------------*/
#include <stdio.h>
#include <conio.h>
#include <iostream.h>
//Nama : Reza Hidayatulloh
//Nim : 3420210019
//Prodi : Teknik Informatika
void main ()
{
int a;
for (a=1;a<=10;a++)
{
cout<<"Ini Adalah Baris Ke - " <<a<<endl;
}
getch ();
}
tugas 2
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
puts ("---------------------------");
puts (" Program For Bersarang ");
puts ("---------------------------");
int a,b;
for (a=1;a<=4;a++) {
for (b=2;b<=2;b++) {
printf("Latihan Algoritma \n");
cout<<endl;
}
}
getch ();
}
tugas 3
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int a,b;
for (a=1;a<=5;a++)
{
printf ("\n");
for (b=a;b<=5;b++)
{
printf ("%d",a);
}
}
getch ();
}
tugas 4
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int a,b;
char lagi;
atas:
clrscr();
cout<<"Masukan Bilangan = ";cin>>a;
b = a % 2;
printf ("Nilai %d %% 2 adalah = %d",a,b);
printf ("\n\nIngin Hitung Lagi [Y/T] : ");
lagi = getche ();
if (lagi == 'Y' || lagi == 'y') { goto atas; }
getch();
}
tugas 5
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int bil = 1;
while (bil<=10)
{
printf (" %d ",bil);
bil++;
}
bil = 2;
cout<<endl;
do
{
printf (" %d ",bil);
bil+=2;
} while (bil <=10);
getch();
}
tugas 6
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int bil = 2;
int b=0;
do
{
if (bil <20) { printf (" %d +",bil); }
else {printf (" %d = ",bil); }
b = b + bil;
bil = bil + 2;
} while (bil<=20);
cout<<b;
getch();
}
tugas7
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int a,b,c;
for (a=2;a<=10;a+=2)
{
b=2; c=0;
do
{
c = c + b;
if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" + ";}
b = b + 2;
}while (b<=a);
cout<<endl;
}
getch();
}
tugas 8
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama : Reza hidaytulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int a,b,c;
for (a=1;a<=9;a+=2)
{
b=1; c=1;
do
{
c = c * b;
if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" * ";}
b = b + 2;
}while (b<=a);
cout<<endl;
}
getch();
}
No comments:
Post a Comment