manda tambunan
Minggu, 30 Juni 2013
Rabu, 04 April 2012
Program pascal
(**********************************************
* pemrogram : moh. rizky rahmanda *
* nim : 1108101010010 *
* fakultas : mipa matematika *
* universitas : syiah kuala *
* compiler : turbo pascal 7.0 *
* cpu : amd dual-core processor c60 *
* with turbo core technology up to 1.333 ghz *
**********************************************)
program pertamaku;
uses crt; {memanggil unit crt}
label keluar, ulang; {memasang label goto keluar}
var a, b, c, d : real;
x1, x2 : real;
f : text;
namafile : string;
directory : string[20];
simpan, ulangi : char;
procedure judul;
begin
writeln(' ******************************************************************');
writeln(' * *');
writeln(' * program menghitung nilai akar x1 dan x2 dari ax^2 + bx + c = 0 *');
writeln(' * *');
writeln(' ******************************************************************');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' ******************************************************************');
writeln;
end;
procedure tunggu;
var d : integer;
s : string[63];
begin
s := '< < < < < < < < <s i l a h k a n t u n g g u> > > > > > > > >';
for d := 1 to 62 do {perulangan membuat efek loading}
begin
delay(85);
write(s[d]);
end;
writeln;
writeln;
end;
begin
repeat
clrscr;
judul;
gotoxy(10,7);
write('nilai a = ');
readln(a);
writeln;
gotoxy(10, wherey);
write('nilai b = ');
readln(b);
writeln;
gotoxy(10, wherey);
write('nilai c = ');
readln(c);
writeln;
d := sqr(b) - 4 * a * c;
if d < 0 then {memeriksa nilai d}
begin
gotoxy(10, 17);
tunggu;
gotoxy(10, 13);
write('persamaan kuadrat tidak memiliki akar real');
writeln;
writeln;
gotoxy(10, wherey);
write('tekan sembarang tombol');
readkey;
goto keluar;
end;
x1 := ( -b + sqrt(d) ) / ( 2 * a );
x2 := ( -b - sqrt(d) ) / ( 2 * a );
gotoxy(10, 17);
tunggu;
clrscr;
judul;
gotoxy(10, 7);
writeln('--------------------------------------------------------------');
gotoxy(10, wherey);
writeln('| persamaan kuadrat | nilai x1 | nilai x2 |');
gotoxy(10, wherey);
writeln('--------------------------------------------------------------');
gotoxy(10, wherey);
writeln('| (',a:0:2,')x^2+(',b:0:2,')x+(',c:0:2,')=0 | ',x1:0:2,' | ',x2:0:2,' |');
gotoxy(10, wherey);
writeln('--------------------------------------------------------------');
writeln;
gotoxy(10, wherey);
write('simpan (y/t) ? ');
readln(simpan);
if (simpan = 'Y') or (simpan = 'y') then
begin
{$i-}
clrscr;
judul;
ulang :
mkdir('c:\14101994'); {membuat folder}
if ioresult = 0 then {jika direktori bisa dibuat}
goto ulang;
chdir('c:\14101994'); {membuka direktori}
gotoxy(10, 7);
write('nama file ? '); {proses membuat file}
readln(namafile);
assign(f, namafile + '.txt');
rewrite(f);
writeln(f,'******************************************************************');
writeln(f,'* *');
writeln(f,'* program menghitung nilai akar x1 dan x2 dari ax^2 + bx + c = 0 *');
writeln(f,'* *');
writeln(f,'******************************************************************');
writeln(f,'* *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* | persamaan kuadrat | nilai x1 | nilai x2 | *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* | (',a:0:2,')x^2+(',b:0:2,')x+(',c:0:2,')=0 | ',x1:0:2,' | ',x2:0:2,' | *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* | -Moh. Rizky Rahmanda- | *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* *');
writeln(f,'******************************************************************');
append(f);
close(f); {akhir dari proses membuat file}
getdir(0,directory); {mencari alamat direktori}
writeln;
gotoxy(10, wherey);
writeln('file akan disimpan di ', directory);
writeln;
gotoxy(10, 17);
tunggu;
gotoxy(10, 11);
writeln('selesai');
writeln;
gotoxy(10, wherey);
write('tekan sembarang tombol');
readkey;
end;
keluar :
clrscr;
judul;
gotoxy(10, 7);
write('ulangi (y/t) ? '); {untuk melakukan proses ulangi}
readln(ulangi);
until (ulangi = 't') or (ulangi= 'T');
end.
* pemrogram : moh. rizky rahmanda *
* nim : 1108101010010 *
* fakultas : mipa matematika *
* universitas : syiah kuala *
* compiler : turbo pascal 7.0 *
* cpu : amd dual-core processor c60 *
* with turbo core technology up to 1.333 ghz *
**********************************************)
program pertamaku;
uses crt; {memanggil unit crt}
label keluar, ulang; {memasang label goto keluar}
var a, b, c, d : real;
x1, x2 : real;
f : text;
namafile : string;
directory : string[20];
simpan, ulangi : char;
procedure judul;
begin
writeln(' ******************************************************************');
writeln(' * *');
writeln(' * program menghitung nilai akar x1 dan x2 dari ax^2 + bx + c = 0 *');
writeln(' * *');
writeln(' ******************************************************************');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' * *');
writeln(' ******************************************************************');
writeln;
end;
procedure tunggu;
var d : integer;
s : string[63];
begin
s := '< < < < < < < < <s i l a h k a n t u n g g u> > > > > > > > >';
for d := 1 to 62 do {perulangan membuat efek loading}
begin
delay(85);
write(s[d]);
end;
writeln;
writeln;
end;
begin
repeat
clrscr;
judul;
gotoxy(10,7);
write('nilai a = ');
readln(a);
writeln;
gotoxy(10, wherey);
write('nilai b = ');
readln(b);
writeln;
gotoxy(10, wherey);
write('nilai c = ');
readln(c);
writeln;
d := sqr(b) - 4 * a * c;
if d < 0 then {memeriksa nilai d}
begin
gotoxy(10, 17);
tunggu;
gotoxy(10, 13);
write('persamaan kuadrat tidak memiliki akar real');
writeln;
writeln;
gotoxy(10, wherey);
write('tekan sembarang tombol');
readkey;
goto keluar;
end;
x1 := ( -b + sqrt(d) ) / ( 2 * a );
x2 := ( -b - sqrt(d) ) / ( 2 * a );
gotoxy(10, 17);
tunggu;
clrscr;
judul;
gotoxy(10, 7);
writeln('--------------------------------------------------------------');
gotoxy(10, wherey);
writeln('| persamaan kuadrat | nilai x1 | nilai x2 |');
gotoxy(10, wherey);
writeln('--------------------------------------------------------------');
gotoxy(10, wherey);
writeln('| (',a:0:2,')x^2+(',b:0:2,')x+(',c:0:2,')=0 | ',x1:0:2,' | ',x2:0:2,' |');
gotoxy(10, wherey);
writeln('--------------------------------------------------------------');
writeln;
gotoxy(10, wherey);
write('simpan (y/t) ? ');
readln(simpan);
if (simpan = 'Y') or (simpan = 'y') then
begin
{$i-}
clrscr;
judul;
ulang :
mkdir('c:\14101994'); {membuat folder}
if ioresult = 0 then {jika direktori bisa dibuat}
goto ulang;
chdir('c:\14101994'); {membuka direktori}
gotoxy(10, 7);
write('nama file ? '); {proses membuat file}
readln(namafile);
assign(f, namafile + '.txt');
rewrite(f);
writeln(f,'******************************************************************');
writeln(f,'* *');
writeln(f,'* program menghitung nilai akar x1 dan x2 dari ax^2 + bx + c = 0 *');
writeln(f,'* *');
writeln(f,'******************************************************************');
writeln(f,'* *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* | persamaan kuadrat | nilai x1 | nilai x2 | *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* | (',a:0:2,')x^2+(',b:0:2,')x+(',c:0:2,')=0 | ',x1:0:2,' | ',x2:0:2,' | *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* | -Moh. Rizky Rahmanda- | *');
writeln(f,'* -------------------------------------------------------------- *');
writeln(f,'* *');
writeln(f,'******************************************************************');
append(f);
close(f); {akhir dari proses membuat file}
getdir(0,directory); {mencari alamat direktori}
writeln;
gotoxy(10, wherey);
writeln('file akan disimpan di ', directory);
writeln;
gotoxy(10, 17);
tunggu;
gotoxy(10, 11);
writeln('selesai');
writeln;
gotoxy(10, wherey);
write('tekan sembarang tombol');
readkey;
end;
keluar :
clrscr;
judul;
gotoxy(10, 7);
write('ulangi (y/t) ? '); {untuk melakukan proses ulangi}
readln(ulangi);
until (ulangi = 't') or (ulangi= 'T');
end.
pertemuan 6 versi 2
#include <stdio.h>
#include <conio.h>
int main(void)
{
int data[150];
int i, maks, min, n;
float jumlah = 0, ratarata;
printf("banyak data ? ");
scanf("%d", &n);
clrscr();
for(i=0; i<n; i++)
{
printf("masukkan data ke-%d ? ",i+1);
scanf("%d",&data[i]);
if(i == 1)
{
min = data[1];
maks = data[1];
}
if(data[i] < min)
min = data[i];
if(data[i] > maks)
maks = data[i];
clrscr();
jumlah += data[i];
}
printf("data minimum -> %d\n\n", min);
printf("data maksimum -> %d\n\n", maks);
ratarata = jumlah / n;
printf("data rata-rata -> %f", ratarata);
getch();
return 0;
}
#include <conio.h>
int main(void)
{
int data[150];
int i, maks, min, n;
float jumlah = 0, ratarata;
printf("banyak data ? ");
scanf("%d", &n);
clrscr();
for(i=0; i<n; i++)
{
printf("masukkan data ke-%d ? ",i+1);
scanf("%d",&data[i]);
if(i == 1)
{
min = data[1];
maks = data[1];
}
if(data[i] < min)
min = data[i];
if(data[i] > maks)
maks = data[i];
clrscr();
jumlah += data[i];
}
printf("data minimum -> %d\n\n", min);
printf("data maksimum -> %d\n\n", maks);
ratarata = jumlah / n;
printf("data rata-rata -> %f", ratarata);
getch();
return 0;
}
Senin, 02 April 2012
pertemuan 6 prak. pemrograman
#include <stdio.h>
#include <conio.h>
int main(void)
{
int data[150];
int i, j, tukar, n;
float jumlah = 0, ratarata;
printf("banyak data ? ");
scanf("%d", &n);
clrscr();
for(i=0; i<n; i++)
{
printf("masukkan data ke-%d ? ",i+1);
scanf("%d",&data[i]);
clrscr();
}
printf("data yang anda masukkan\n\n");
for(i=0; i<n; i++)
{
printf("%d ",data[i]);
jumlah += data[i];
}
for(j=0; j<n; j++)
{
for(i=0; i<n; i++)
{
if(data[i] > data[i+1])
{
tukar = data[i];
data[i] = data[i+1];
data[i+1] = tukar;
}
}
}
printf("\n\ndata minimum -> %d\n\n", data[0]);
printf("data maksimum -> %d\n\n", data[n-1]);
ratarata = jumlah / n;
printf("data rata-rata -> %f", ratarata);
getch();
return 0;
}
#include <conio.h>
int main(void)
{
int data[150];
int i, j, tukar, n;
float jumlah = 0, ratarata;
printf("banyak data ? ");
scanf("%d", &n);
clrscr();
for(i=0; i<n; i++)
{
printf("masukkan data ke-%d ? ",i+1);
scanf("%d",&data[i]);
clrscr();
}
printf("data yang anda masukkan\n\n");
for(i=0; i<n; i++)
{
printf("%d ",data[i]);
jumlah += data[i];
}
for(j=0; j<n; j++)
{
for(i=0; i<n; i++)
{
if(data[i] > data[i+1])
{
tukar = data[i];
data[i] = data[i+1];
data[i+1] = tukar;
}
}
}
printf("\n\ndata minimum -> %d\n\n", data[0]);
printf("data maksimum -> %d\n\n", data[n-1]);
ratarata = jumlah / n;
printf("data rata-rata -> %f", ratarata);
getch();
return 0;
}
Kamis, 29 Maret 2012
pertemuan 5 permasalahan b prak. pemrograman
#include <stdio.h>
#include <conio.h>
int main(void)
{
float a, b;
char pilihan;
do {
clrscr();
printf("1. A^2 + B^2\n\n2. A^2 - B^2\n\n3. A^2 * B^2\n\n4. A^2 / B^2\n\n5. Keluar\n\n");
printf("(1 / 2 / 3 / 4 / 5) -> ");
scanf("%c", &pilihan);
clrscr();
switch(pilihan)
{
case '1' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 + B^2 = %f", a * a + b * b);
getch();
break;
case '2' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 - B^2 = %f", a * a - b * b);
getch();
break;
case '3' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 * B^2 = %f", a * a * b * b);
getch();
break;
case '4' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 / B^2 = %f", a * a / b * b);
getch();
break;
case '5' :
break;
default :
break;
}
} while(pilihan < '5' || pilihan > '5');
return 0;
}
#include <conio.h>
int main(void)
{
float a, b;
char pilihan;
do {
clrscr();
printf("1. A^2 + B^2\n\n2. A^2 - B^2\n\n3. A^2 * B^2\n\n4. A^2 / B^2\n\n5. Keluar\n\n");
printf("(1 / 2 / 3 / 4 / 5) -> ");
scanf("%c", &pilihan);
clrscr();
switch(pilihan)
{
case '1' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 + B^2 = %f", a * a + b * b);
getch();
break;
case '2' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 - B^2 = %f", a * a - b * b);
getch();
break;
case '3' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 * B^2 = %f", a * a * b * b);
getch();
break;
case '4' :
printf("A -> ");
scanf("%f", &a);
printf("\nB -> ");
scanf("%f", &b);
printf("\nA^2 / B^2 = %f", a * a / b * b);
getch();
break;
case '5' :
break;
default :
break;
}
} while(pilihan < '5' || pilihan > '5');
return 0;
}
Senin, 26 Maret 2012
pertemuan 4 prak. pemrograman
#include <stdio.h> #include <conio.h> int main(void) { char nama[255]; char pangkat1, pangkat2; int gajipokok; int konstanta; int tunjangan; int totalgaji; int salahinput; salahinput = 1; printf("nama : "); gets(nama); printf("pangkat : "); scanf("%c%c", &pangkat1, &pangkat2); switch(pangkat1) { case '1' : switch(pangkat2) { case 'a' : konstanta = 0; tunjangan = 15000; break; case 'b' : konstanta = 1; tunjangan = 20000; break; case 'c' : konstanta = 2; tunjangan = 25000; break; case 'd' : konstanta = 3; tunjangan = 30000; break; default : salahinput = 0; } break; case '2' : switch(pangkat2) { case 'a' : konstanta = 4; tunjangan = 40000; break; case 'b' : konstanta = 5; tunjangan = 50000; break; case 'c' : konstanta = 6; tunjangan = 60000; break; case 'd' : konstanta = 7; tunjangan = 70000; break; default : salahinput = 0; } break; case '3' : switch(pangkat2) { case 'a' : konstanta = 8; tunjangan = 120000; break; case 'b' : konstanta = 9; tunjangan = 170000; break; case 'c' : konstanta = 10; tunjangan = 220000; break; case 'd' : konstanta = 11; tunjangan = 270000; break; default : salahinput = 0; } break; case '4' : switch(pangkat2) { case 'a' : konstanta = 12; tunjangan = 470000; break; case 'b' : konstanta = 13; tunjangan = 870000; break; case 'c' : konstanta = 14; tunjangan = 1670000; break; case 'd' : konstanta = 15; tunjangan = 3270000; break; case 'e' : konstanta = 16; tunjangan = 6470000; break; default : salahinput = 0; } break; default : salahinput = 0; } if(salahinput == 1) { gajipokok = 150000 + konstanta * 16000; totalgaji = gajipokok + tunjangan; printf("\ngaji -> Rp. %d", totalgaji); } else printf("\ntidak ada pangkat %c%c", pangkat1, pangkat2); getch(); return 0; }
Sabtu, 24 Maret 2012
pertemuan 5 prak. pemrograman
#include <stdio.h>
#include <conio.h>
int main(void)
{
int i, j, n, jumlah = 0;
printf("banyak data ? ");
scanf("%d", &n);
for(i = 1; i <= n; i++)
{
if(i%2 == 0)
j = -i;
else
j = i;
jumlah += j;
}
printf("\nhasilnya %d", jumlah);
getch();
return 0;
}
#include <conio.h>
int main(void)
{
int i, j, n, jumlah = 0;
printf("banyak data ? ");
scanf("%d", &n);
for(i = 1; i <= n; i++)
{
if(i%2 == 0)
j = -i;
else
j = i;
jumlah += j;
}
printf("\nhasilnya %d", jumlah);
getch();
return 0;
}
Langganan:
Postingan (Atom)