Shu'aibu 407 Assignment

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Name: SHU'

AIBUIBRAHIM
Adm no.1910203058
Dept: COMPUTERSCI ENCEDEPT
Course: CSC407
Ti
tl
e: ASSIGNMENT
Date: 6thmay,2024

QUESTION:
Q1.WRITEAPROGRAM TODRAW LI
NEUSI NGTURBOCOMPI
LERPRINTTHEOUTPUT
Q2.WRITEAPROGRAM THATMAKETHECOMPUTERSCREENSAVERPRINTDYNAMIC
SHAPES.
Answer
Here'
sasimpl
epr
ogram i
nCusi
ngTurboCcompil
ertodr
awal
ine:

#i
ncl
ude<graphics.
h>
#i
ncl
ude<st
dli
b.h>
#i
ncl
ude<st
dio.
h>

i
ntmai n(
){
i
ntgd=DETECT,gm;
i
nit
graph(
&gd,
&gm,"
C:\
\TURBOC3\
\BGI
")
;

/
/Drawalinefr
om (100,
100)t
o(300,
300)
l
i
ne(
100,100,300,
300);

getch()
;
closegr
aph(
);
retur
n0;
}

Andher
e'sabasi
cpr
ogr
am i
nCt
ocr
eat
eady
nami
cscr
eensav
erwi
thmov
ingshapes:

#i
ncl
ude<graphics.
h>
#i
ncl
ude<stdl
ib.
h>
#i
ncl
ude<stdi
o.h>
#i
ncl
ude<dos.h>

i
ntmai n(
){
i
ntgd=DETECT,gm;
i
nit
graph(
&gd,
&gm,"
C:\
\TURBOC3\
\BGI
")
;

i
ntx=100,y=100;
i
ntdx=5,dy=3;
i
ntradi
us=50;

whi
l
e(!
kbhi
t(
)){
cl
ear
devi
ce()
;
//Drawacircl
e
cir
cle(
x,y
,radi
us)
;
delay(
50)
;

//Mov
etheci
rcl
e
x+=dx;
y+=dy;

/
/Bounceoffthewal
ls
i
f(x<=0||x>=getmaxx(
)){
dx=-
dx;
}
i
f(y<=0||
y>=getmaxy (
)){
dy=-
dy;
}
}

getch()
;
closegr
aph(
);
retur
n0;
}

Theseprogramsshoul
druni
nTur
boCcompi
l
eranddi
spl
ayal
i
neandamov
ingci
rcl
e
respect
ivel
y

You might also like