Soal Algoritma (10)

BY IN Ilmu Komputer Comments Off on Soal Algoritma (10)

1. Coba anda analisa program berikut ini, jelaskan apa yang dilakukan program dan bagaimana outputnya ! (sangat dianjurkan untuk penjelasan per baris program satu persatu)

#include <stdio.h>
#include <conio.h>

void tulisan(int x, int y, char *st)
{
gotoxy(x,y); cprintf(“%s”,st);
}

void warna(int x, int y)
{
textcolor(x); textbackground(y);
}

void buatkotak()
{
int i,j;
warna(15,0); tulisan(20,10,”\xC9″); tulisan(20,14,”\xC8″);
for(i=1;i<=39;i++)
{
tulisan(20+i,10,”\xCD”); tulisan(20+i,14,”\xCD”);
}
tulisan(60,10,”\xBB”); tulisan(60,14,”\xBC”);
for(j=1;j<=3;j++)
{
tulisan(20,10+j,”\xBA”); tulisan(60,10+j,”\xBA”);
}
}

main()
{
textcolor(10); clrscr();
gotoxy(10,1); warna(14,1);
cprintf(“Hallo…”); tulisan(10,2,”Selamat Datang di Dunia C”);
buatkotak();
getch();
}




Comments are closed.