TUGAS PERTEMUAN 6 ALGORITMA DAN STRUKTUR DATA
Assalamualaikum wr.wb
TUGAS PERTEMUAN 6 ALGORITMA
Nama : Raihan Fajarahmatan
Nim: 3420210010
Prodi: Teknik Informatika
TUGAS 6.1
/*------------------------------*/
/* Program For - Bilangan Naik */
/*------------------------------*/
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
void main()
{
int a;
for (a=1;a<=20;a++)
{
cout<<"Ini Adalah Baris Ke - " <<a<<endl;
}
getch ();
}
TUGAS 6.2
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
*/
void main () {
puts("----------------------");
puts(" Program For Besarang ");
puts("----------------------");
int a,b;
for (a=2;a<=6;a++) {
for (b=2;b<=4;b++) {
printf("RAIHAN FAJARAHMATAN \n");
}
}
getch();
}
TUGAS 6.3
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
*/
void main()
{
int a,b;
for (a=2;a<6;a++)
{
printf("\n");
for (b=a;b<=6;b++)
{
printf("%d",a);
}
}
getch();
}
TUGAS 6.4
TUGAS 6.8
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
*/
void main()
{
int a,b;
char lagi;
atas:
clrscr();
cout<<"Masukan Bilangan = ";cin>>a;
b = a % 3;
printf("Nilai %d %% 3 adalah = %d",a, b);
printf("\n\nIngin Hitung lagi [Y/N] : ");
lagi = getche ();
if (lagi == 'Y' || lagi == 'y') {goto atas; }
getch();
}
TUGAS 6.5
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
*/
void main()
{
int bil=2;
while (bil<=20)
{
printf(" %d ",bil);
bil++;
}
bil=4;
cout<<endl;
do
{
printf(" %d ",bil);
bil+=4;
}while(bil<=20);
getch();
}
TUGAS 6.6
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
*/
void main()
{
int bil=3;
int b=1;
do
{
if (bil <30) { printf (" %d +",bil); }
else { printf(" %d = ",bil); }
b = b + bil;
bil = bil + 3;
}while(bil<=30);
cout<<b;
getch();
}
TUGAS 6.7
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
*/
void main()
{
int a,b,c;
for (a=3;a<=30;a+=3)
{
b=3; c=0;
do
{
c = c + b;
if (a == b) {cout<<b<<" = "<<c;} else {cout<<b<<" + ";}
b = b + 3;
}while(b<=a);
cout<<endl;
}
getch();
}
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
/*
//Nama = Raihan Fajarahmatan
//NIM = 3420210010
//Prodi = Teknik Informatika
*/
void main()
{
int a,b,c;
for (a=1;a<=11;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();
}
SEKIAN DAN TERIMAKASIH
WASSALAMUALAIKUM WR.WB
Komentar
Posting Komentar