Nama : Reza Hidayatulloh
Nim : 3420210019
Prodi : Teknik Informatika
Tugas1
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
//Nama : Reza Hidayatulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void main()
{
int i;
int a = 5;
int b = 10;
cout<<"-------------------------------\n";
cout<<" No A B A*A B*B\n";
cout<<"-------------------------------\n";
for(i=1;i<=10;i++)
{
gotoxy(2,3+i);cout<<i;
gotoxy(6,3+i);cout<<a;
gotoxy(12,3+i);cout<<b;
gotoxy(17,3+i);cout<<a*a;
gotoxy(22,3+i);cout<<b*b;
a=a+4;
b=b+2;
cout<<"\n";
}
cout<<"-------------------------------\n";
getch();
}
Tugas2
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
//Nama : Reza Hidayatulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void judul(){
puts("====================================");
puts("\tContoh Array Dimensi 1");
puts("====================================");
}
void main()
{
judul();
int i;
float harga [5];
harga[0]=1000;
harga[1]=2000;
harga[2]=3000;
harga[3]=4000;
harga[4]=5000;
harga[5]=6000;
printf("Variable harga 1 adalah %.0f\n",harga[1]);
printf("Variable harga 3 adalah %.0f\n",harga[3]);
for(i=1;i<=3;i++)
{
cout<<endl;
}
puts("Nilai dari Seluruh Variabel adalah:");
for(i=0;i<5;i++)
{
printf("variabel harga %d adalah %.0f\n",i,harga[i]);
}
getch();
}
Tugas3
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
//Nama : Reza Hidayatulloh
//Nim : 3420210019
//Prodi: Teknik Informatika
void judul () {
puts("========================================");
puts(" Contoh Array Dimensi 2 ");
puts("========================================");
}
void main() {
judul();
int i;
char hari[7][10]={"Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu"};
printf("Hari ke 4 adalah %s\n",hari[4]);
printf("Hari ke 5 adalah %s\n",hari[5]);
for(i=1;i<=5;i++) { cout<<endl; }
puts("Nilai dari seluruh variable hari adalah:");
for(i=0;i<7;i++) {
printf("Variable hari %d adalah %s\n",i,hari[i]);
}
getch();
}
No comments:
Post a Comment