5th sem prct solution for niit kuvempu university

25
KU 5TH SEM PRACTICAL SOLUTIONS By: Rajiv Phukan (ৰজৱ ফকন) Pathsala(পঠশল ) Set 1 //1. Open an Image. And separate background using selection tool. Step 1: run Photoshop Step 2: go to file menu -> open Step 3 : select image ->click open Step 4: click on magic wand tool from tool menu Step 5: select on background of the image using magic wand tool Step 6 : press delete on keyboard Step 7: go to file menu -> save as Step 8 : select JPEG format Step 9: enter file name -> click SAVE //2. Write a JSP page to display the number of hits to this page. (Hint: use application scope of java bean). <%@ page session="false" %> <HTML> <HEAD> <TITLE>Page Counter Using URL Rewriting</TITLE> </HEAD> <BODY> <H3 >Page Counter Using URL Rewriting</H3 > <% int count = 0; String parm = request.getParameter("count"); if (parm != null) count = Integer.parseInt(parm); if (count == 0) { %> This is the first time you have accessed this page. <% } else if (count == 1) {

Upload: gulanchi

Post on 01-Dec-2015

614 views

Category:

Documents


0 download

DESCRIPTION

niit, kuvempu, bsc IT, practical, solution, 6th sem

TRANSCRIPT

Page 1: 5th sem prct solution for NIIT kuvempu University

KU 5TH SEM PRACTICAL SOLUTIONSBy: Rajiv Phukan (ৰ�জ�ৱ ফকন) Pathsala(প�ঠশ�ল� )

S e t 1

//1. O pe n a n I m a ge. A n d se p a r a t e b ac k g r o u n d u s i n g s elec tio n t ool.

Step 1: run PhotoshopStep 2: go to file menu -> open Step 3 : select image ->click openStep 4: click on magic wand tool from tool menuStep 5: select on background of the image using magic wand toolStep 6: press delete on keyboardStep 7: go to file menu -> save asStep 8: select JPEG formatStep 9: enter file name -> click SAVE

//2. W r i te a J S P p a ge t o di s pl a y t h e n u m b e r of h i t s t o t h i s p age. (Hi n t : u s e a p plic a t io n sco pe of j a v a be a n ).

<%@ page session="false" %><HTML><HEAD><TITLE>Page Counter Using URL Rewriting</TITLE></HEAD><BODY><H3 >Page Counter Using URL Rewriting</H3 ><%int count = 0;String parm = request.getParameter("count");if (parm != null)count = Integer.parseInt(parm);if (count == 0) {%> This is the first time you have accessed this page. <%}else if (count == 1) {

Page 2: 5th sem prct solution for NIIT kuvempu University

%> You have accessed the page once before.<%}else {%> You have accessed the page <%= count %> times before.<%}%><P> Click<A HREF="urlrewriting.jsp?count=<%=count + 1 %>">here</A> to visit the page again.</BODY></HTML>

S e t 2

//1. U s i n g pe n cil t ool c re a te a n i m a ge of l a n d sc a pe, a n d colo r i t w i t h B r u s h t ool.

Step 1: run PhotoshopStep 2: click file menu -> new -> select size -> press OKStep 3 : in dialog box, click on preset -> select landscape in size box -> press OKStep 4: click on pencil tool in tool menuStep 5: draw an image in landscape using pencil toolStep 6: right click on pencil tool and select brush toolStep 7: using brush tool, fill the color in landscape imageStep 8: go to file menu -> save asStep 9: select JPEG formatStep 10: enter file name -> click SAVE

//2. C r e a t e a n H TM L p a ge con t ai ni n g t h e f oll o w i n g f e a t u r e sa. C r e a te a login J S P p a ge w i t h u s e r n a m e , p a s s w o r d a n d s u b m i t b u t t o n. b. O n s u b m i t , di s pl ay m e s s a ge ‘ T h a n k yo u f o r loggi ng in’ a l so c re a te coo k ie s t o s t o re u s e r n a m e a n d p a s s w o r d.c. O pe n login J S P p a ge o n a n e w b r o w s e r. I f t h e coo k ie i s p re se n t t h e u s e r n a m e a n d p a s s w o r d f ield s h o u ld be a u t o m a t ic al l y po p u l a te d w i t h t h e v a l u e s f r o m t h e coo k ie.

<%@page contentType="text/html"%><html>

Page 3: 5th sem prct solution for NIIT kuvempu University

<head><title></title></head><body><center><form action="next.jsp" method="post"> Please Enter Your Detials !<br> First Name <input type="text" name="firstname"><br> Last Name <input type="text" name="lastname"><br><input type="submit" name="submit" value="Submit"></form></center></body></html>

N e x t. j s p

<%@page contentType="text/html"%><%@page pageEncoding="UTF-8"%><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>JSP Page</title></head><body><% String firstname=request.getParameter("firstname"); String lastname=request.getParameter("lastname");

out.println("<font color=blue>Welcome</font> "+firstname+" "+lastname+" Thank you for loging in!"); %></body></html> 

S e t 3

Page 4: 5th sem prct solution for NIIT kuvempu University

//1. W r i te a J S P p r og r a m t o di s pl a y c u r re n t d a t e a n d t i m e a n d s u i t a ble w e l co m e m e s s a ge. a . I f t i m e i s be t w e e n 5 AM a n d 12 PM di s pl a y w e l co m e m e s s a ge a s ‘ Good Mor ni n g’b. I f t i m e i s be t w e e n 12 PM a n d 5 PM dis pl ay w e l co m e m e s s a ge a s ‘ Good A f t e r n oo n’c. A f t e r 5 PM dis pl ay m e s s a ge a s ‘Good e ve ni n g’.

<%@page language="java"%><html><head><title>Welcome</title></head><body><h1> <% java.util.Date d=new java.util.Date(); int time=d.getHours(); if(time>5 && time<12) out.println("\n Good Morning !"); esle if(time>12 && time<17) out.println("\n Good Afternoon !"); else if(time>17) out.println("\n Good Evening !"); %></h1>current time is :<%=d.getHours()%>:<%=d.getMinutes()%></body></html>

//2. U s i n g R u bbe r s t a m p t ool , c re a te a clon e i m a ge

Step 1: run PhotoshopStep 2: go to file menu -> open Step 3 : select image -> click openStep 4: select rubberstamp tool from tool menuStep 5: press ALT then left click on image to beginStep 6: click on the image and drag where you want to make clone of that imageStep 7: go to file -> save as

Page 5: 5th sem prct solution for NIIT kuvempu University

Step 8: select JPEG formatStep 9: enter file name -> click SAVE 

S e t 4

//1. U s i n g G r a die n t t ool , c re a te s o m e b ac k g r o u n d s f o r p h o to s.

Step 1: run PhotoshopStep 2: go to file menu -> new -> select size -> press okStep 3 : select gradient tool from tool menuStep 4: choose gradient (linear/ radial/ angle/ diamond) from option toolbarStep 5: press left click on mouse then drag on image to create gradientStep 6: go to file -> save asStep 7: select JPEG formatStep 8: enter file name -> click SAVE

//2. .C re a t e a n H TML p age con t ai n i n g t h e f ol l o w i n g f e a t u r e sa. A co m b o b ox co n t ai n i n g t h e l i s t o f 7 colo r s : V i ole t , In digo, B l u e, G r ee n , Ye l lo w, O r a n ge, R e db. De pe n di n g u p o n t h e colo r s elec ted f r o m t h e a b o ve co m b o b ox, t h e m e s s a ge in t h e s t a t u s b a r of t h e w i n d o w m u s t be r e f lec t t h e v a l u e selec ted in t h e co m bo box ( h i n t : on c h a n ge e ve n t of t h e co m bo box ).

<html><head><title>Showing Message in Status Bar</title></head><body><script language="JavaScript">functionfn() { num=document.frm.vibgyor.selectedIndex; if(num==0) {window.status="You have selected Violet."; } if(num==1) {window.status="You have selected Indigo.";

Page 6: 5th sem prct solution for NIIT kuvempu University

} if(num==2) {window.status="You have selected Blue."; } if(num==3 ) {window.status="You have selected Green."; } if(num==4) {window.status="You have selected Yellow."; } if(num==5) {window.status="You have selected Orange."; } if(num==6) {window.status="You have selected Red."; } } </script><form name="frm"><select name="vibgyor" onChange=fn()><option>Violet</option><option>Indigo</option><option>Blue</option><option>Green</option><option>Yellow</option><option>Orang</option><option>Red</option></select></form></body>

Page 7: 5th sem prct solution for NIIT kuvempu University

</html> 

S e t 5

//1. C r e a t e a n H TM L p a ge con t ai ni n g t h e f oll o w i n g f e a t u r e sa. A co m b o b ox co n t ai n i n g t h e l i s t o f 7 colo r s : V i ole t , In digo, B l u e, G r ee n , Ye l lo w, O r a n ge, R e db. A n e m p t y 1X1 t a ble w i t h def a u l t b ac k g r o u n d color : W h i t ec. De pe n di n g u po n t h e colo r selec ted f r o m t h e a b o ve co m bo box, t h e b ac k g r o u n d of t h e t a ble m u s t be c h a n ged a cco r di n gly. ( h i n t : o n c h a n ge e ve n t of t h e co m b o box ).

<html> <head> <title> Changing Table Color by selecting color from the ComboBox </title> </head> <body> <script language= "JavaScript"> functionfn() { num=document.frm.vibgyor.selectedIndex; if(num==0) { document.getElementById("tab").bgColor="Violet"; } if(num==1) { document.getElementById("tab").bgColor="Indigo"; } if(num==2) { document.getElementById("tab").bgColor="Blue"; } if(num==3 ) { document.getElementById("tab").bgColor="Green"; } if(num==4)

Page 8: 5th sem prct solution for NIIT kuvempu University

{ document.getElementById("tab").bgColor="Yellow"; } if(num==5) { document.getElementById("tab").bgColor="Orange"; } if(num==6) { document.getElementById("tab").bgColor="Red"; } } </script> <form name="frm"> <select name="vibgyor" onChange=fn()> <option>Violet</option> <option>Indigo</option> <option>Blue</option> <option>Green</option> <option>Yellow</option> <option>Orange</option> <option>Red</option> </select><br><br><br><br> <table id="tab" border="1"> <tr> <th>Name</th> <th>Registration Number</th> </tr> <tr> <td>priyanka rani</td> <td>072B5725</td> </tr> </table> </form> </body>

Page 9: 5th sem prct solution for NIIT kuvempu University

</html>

//2. I m po r t a ‘ J P E G ’ f o r m a t i m a ge a n d s a v e i t a s a ‘ P S D ’ i m a ge, u s i n g l a ye r op tio n sDec re a se t h e op aci t y of i m a ge.T i p s : C t r l + S h i f t + S = ‘s a ve a s ’ w i n d o w

Step 1: run PhotoshopStep 2: go to file menu -> openStep 3 : select a JPEG image -> click openStep 4: go to layer -> new -> click on ‘layer from background’Step 5: enter layer name in dialog box -> press OKStep 6: press F7 then decrease opacityStep 7: go to file -> save asStep 8: select PSD formatStep 9: enter file name -> click SAVE 

S e t 6

//1. O pe n a P O R T R A I T i m a ge, co n ve r t i t in to g r a y sc ale. N o w colo r t h e i m a ge U s i n g C O L O R B A L A N C E , L E V E L S a n d C U RV E S

Step 1: run PhotoshopStep 2: go to file menu -> openStep 3 : select a portrait JPEG image ->click open Step 4: go to image -> mode -> click on GrayscaleStep 5: click “discard” in message boxStep 6: go to image -> adjustments -> image -> click on ‘curves’Step 7: adjust curves -> press OKStep 8: go to file -> save asStep 9: select JPEG formatStep 10: enter file name -> click SAVE

//2. W r i te a H TML p a ge co n t ai n i n g a n H TML f o r m t o c ap t u r e t h e f ol lo w i n g p r o pe r t ie s f r o m t h e u s e r :a . N a m e ( t ex t b ox )b. A d d r e s s ( t ex t a r e a )c. P h o n e ( t ex t b ox )

W r i te j a v a sc r ip t f u n c t io n s a . t o v a l id a te N a m e t o co n t ai n o n l y a l p h ab e t s a n d of m a xi m u m le n g t h

Page 10: 5th sem prct solution for NIIT kuvempu University

s h o u ld be 25 ; S h o w a p p r o p r i a te m e s s a ge s on f a il u r e b. t o v a l id a te A d d r e s s f ield t o con t ai n m a xi m u m len g t h of 200 c h a r ac te r s ; S h o w a p p r o p r i a t e o n f ai l u r e a n d f oc u s t h e ‘ A dd r e s s ’ f ield t ex t a r e ac. t o v a l id a t e p h o n e n u m b e r t o con t ai n o n ly n u m e r ic d a t a ; s h o w a p p r o p r i a te m e s s a ge s on f a il u r e

<html><head><title>HTML form</title><Script language="javaScript">

function f(){ var name=document.f1.Name.value; var phone=document.f1.Phone.value; var address=document.f1.Address.value;

if(name.length=="") { alert("Please enter name"); name.focus(); return; } if (name.length> 25) { alert("Name Field cannot contain more than 25 characters"); name.focus(); return; } if (!isNaN(name)) { alert("Name field must be filled with only Alphabets"); name.focus(); return; }

Page 11: 5th sem prct solution for NIIT kuvempu University

if(phone.length=="") { alert("Please enter phone numbar"); phone.focus(); return; } if (isNaN(phone)) { alert("Phone Number must be numeric"); phone.focus(); return; }

if(address.length=="") { alert("Please enter address"); address.focus(); return; } if (address.length> 200) { alert("Address Field can contain maximum of 200 character"); }}

</script></head><body bgcolor="pink"><marquee><h1 align="center">A Sample FORM </h1></marquee><form name=f1>Name:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=textbox name="Name"><br>Phone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=textbox name="Phone"><br>Address:&nbsp;&nbsp;<textarea rows="5" cols="50" name="Address"></textarea><BR>

Page 12: 5th sem prct solution for NIIT kuvempu University

<input type=Button name=''Button" value ="Submit" onclick=f()></form></body></html> 

S e t 7

//1. C r e a t e t w o H TM L p a ge sa. F i r s t p a ge w i t h t h e f ol lo w i n g f e a t u r e si. A n i m a ge ( logo ) w i t h a co m p a n y n a m e a s t h e h e a di n g in t h e t o p cen te rii. T h i s p age co n t ai n i n g a n H TML f o r m , t w o t ex t boxe s t o ge t F i r s t N a m e , S e co n d N a m e of t h e u s e riii. A s u b m i t b u t t o n t o t h e s u b m i t t h e d a t a t o t h e n ex t p a geb. T h e S e co n d p age r ecei ve s t h e d a t a s u b m i t t ed b y t h e F i r s t P a ge, dis pl ay s t h e f oll o w i n g m e s s a geWe lco m e <La s t N a m e>, <Fi r s t N a m e>

<html><head><title></title></head><body><center><img src="NIITLogo.jpg"></center><center><form action="ToShowDataToAnotherPage" method="post"> Please Enter Your Detials !<br> First Name <input type="text" name="firstname"><br> Last Name <input type="text" name="lastname"><br><input type="submit" name="submit" value="Submit"></form></center></body></html>ToShowDataToAnotherPage servletimport java.io.*;import java.net.*;importjavax.servlet.*;importjavax.servlet.http.*;

Page 13: 5th sem prct solution for NIIT kuvempu University

public class ToShowDataToAnotherPage extends HttpServlet {

protected void doPost(HttpServletRequest request, HttpServletResponse response)throwsServletException, IOException {response.setContentType("text/html;charset=UTF-8");PrintWriter out = response.getWriter();

String firstname=request.getParameter("firstname"); String lastname=request.getParameter("lastname");

out.println("<font color=blue>Welcome</font> "+firstname+" "+lastname); }}

//2. O pe n a po r t r a i t , s elec t t h e e ye b all s u s i n g m a r q u ee t ool , a n d n o w c h a n ge t h e colo r of e ye s u s i n g Hue / s a t u r a t io n.T i p s : C t r l + U = H ue / s a t u r a t io n

Step 1: run PhotoshopStep 2: go to file menu -> openStep 3 : select image ->click openStep 4: click on marquee tool from tool menuStep 5: select eyeball from the image using marquee toolStep 6: press CTRL+UStep 7: adjust HUE AND SATURATION from dialog box -> press OKStep 8: go to file -> save asStep 9: select JPEG formatStep 10: enter file name -> click SAVE 

S e t 8

//1. O pe n 3 t o 4 i m a ge s in a s a m e l a ye r. U s i n g f i l te r e f f ec t s c re a te c re a t i ve b ac k g r o u n d s f o r boo k cove r p age.

Step 1: run PhotoshopStep 2: go to file menu -> new -> select background size -> press OKStep 3 : go to filter -> noise -> add noiseStep 4: adjust amount in noise dialog box -> press OK

Page 14: 5th sem prct solution for NIIT kuvempu University

Step 5: go to file menu -> openStep 6: select 3 -4 images -> click openStep 7: select images, copy and paste them in background one by oneStep 8: go to file -> save asStep 9: select JPEG formatStep 10: enter file name -> click SAVE

//2. C r e a t e a H TML p a ge t o di s pl a y a li s t o f f i l m so n g s a v a i l able in t h e l ib r a r y. T h e f ol lo w i n g a r e f e a t u r e s of t h e p agea. T h e n a m e of t h e so n g s m u s t be h y p e r li n k e d t o t h e s o n g s , so t h a t t h e u s e r s m u s t be a ble t o d o w n l o a d so n g s.b. T h e f ol lo w i n g i s t h e s o n g d a t ab a s e a v a i l a ble in t h e lib r a r y:c. L i b r a r y N a m e : Ha r i h a r a n Mu sic S i t e S l n o S o n g N a m e F i l m A r t i s te 1 PAT A-PAT A A p t h a m i t r a U di t h N a r a y a n 2 K a n a K a n a de A p t h a m i t r a Mad h u b a l a k r i s h n a 3 A n k u Do n k u A p t h a m i t r a S P B al a s u b r a m a n y a m 4 K a l a v a n u T h a d e yo r u A p t h a m i t r a Ha r i h a r a n 5 Bo m be A n a y y a U n k n o w n

<html> <head> <tittle> Hiriharan Songs Site </title> </head> <body><marquee><font color = blue><b>Welcome to Hariharan's Songs Site</b></font></marquee> <center> <table border=1> <tr> <th>S.No.</th> <th>Song Name</th> <th>Film</th> <th>Artist</th> <tr> <tr> <td>1.</td>

Page 15: 5th sem prct solution for NIIT kuvempu University

<td><a href="song1.html">Patta-Patta</a></td> <td>Apthamitra</td> <td>Udit Narayan</td> </tr> <tr> <td>2.</td> <td><a href="song2.html">Kana Kanede</a></td> <td>Apthamitra</td> <td>Madhubalakirishna</td> </tr> <tr> <td>3 .</td> <td><a href="song3 .html">AnkuDonku</a></td> <td>Apthamitra</td> <td>S P Balasupramanniyam</td> </tr> <tr> <td>4.</td> <td><a href="song4.html">Bombay</a></td> <td>Anaya</td> <td>Unknown</td> </tr> </table> </center> </body></html> 

S e t 9

//1. C r e a t e a n H TM L p a ge t o di s pl a y t h e f oll o w i n g d a t a u s i n g <table></table> t a g s

F i r s t N a m e L a s t N a m e C i t y P h o n e N u m b e r S h i v a R a m a Myso re 08212569964P r a t a p S B a n g alo re 08025689754S r e e n i v a s G Merc a r a 08965445454

<html>

Page 16: 5th sem prct solution for NIIT kuvempu University

<head> </head> <tittle> Data Table </title> <body> <table border=1> <tr> <th>First Name</th> <th>Last Name</th> <th>City</th> <th>Phone Number</th> <tr> <tr> <td>Shiva</td> <td>Rama</td> <td>Mysore</td> <td>08212569964</td> </tr> <tr> <td>Pratap</td> <td>S</td> <td>Bangalore</td> <td>08025689754</td> </tr> <tr> <td>Shrinivas</td> <td>G</td> <td>Mercara</td> <td>08965445454</td> </tr> </table> </body></html>

Page 17: 5th sem prct solution for NIIT kuvempu University

//2. O pe n a n i m a ge a n d a dj u s t a le vel of i m a ge. T i p s : C t r l + L = le vel

Step 1: run PhotoshopStep 2: go to file menu -> openStep 3 : select an image -> click openStep 4: go to image -> adjustments -> click on level or press ctrl + lStep 5: adjust level -> press OKStep 6: go to file -> save asStep 7: select JPEG formatStep 8: enter file name -> click SAVE 

S e t 10

//1. W r i te H TM L sc r ip t t o di s pl a y “Hello Wo r ld, We lco m e t o t h e w o r l d of H TM L” . P u t t h e t i t le a s “ Wo r ld of H TM L”

<html> <head> </head> <title> Welcome to the world of HTML </title> <body> <i>"Hello World</i><b>Welcome to the world of HTML"</b> </body></html>

//2. C h a n ge a n i m a ge s ize 22 c m x 29 c m t o 44 c m x 58 c m . a n d r e sol u t io n 72 t o 300.

Step 1: run PhotoshopStep 2: go to file menu -> openStep 3 : select an image with 22 cm x 29 cm size -> click openStep 4: go to image -> image sizeStep 5: change image size to 44 cm x 58 cm size with 100 resolutions -> press OKStep 6: go to file -> save asStep 7: select JPEG formatStep 8: enter file name -> click SAVE

Page 18: 5th sem prct solution for NIIT kuvempu University

S e t 11

//1. C r e a t e so m e geo m e t r ic al s h a pe s , u s i n g s h a p e t ool.

Step 1: run PhotoshopStep 2: go to file menu -> new -> select size -> press OKStep 3 : click on ‘custom shape tool’ from tool menuStep 4: click on ‘custom shape picker’ in options toolbarStep 5: click on smart tag -> select all then click appendStep 6: choose shape from option toolbarStep 7: left click on background and drag mouse to draw shapeStep 8: go to file -> save asStep 9: select JPEG formatStep 10: enter file name -> click Save 

S e t 12

//1. T y p e t ex t ‘ G R A D AT IO N ’ a n d a p p l y g r a die n t t ool o n t ex t.

Step 1: run PhotoshopStep 2: go to file menu -> new -> select size -> click OKStep 3 : click on text from tool menuStep 4: type text “GRADATION”Step 5: click on layer from layer propertyStep 6: right click on selected layer and click on ‘blending options’Step 7: click and check on ‘gradient overlay’Step 8: adjust gradient or change angle to 0o -> then press OKStep 9: go to file menu -> save asStep 10: select JPEG formatStep 11: enter file name -> click SAVE

//2. C r e a t e a n H TM L p a ge t o di s pl a y t h e f oll o w i n g d a t a u s i n g <table></table> t a g sF i r s t N a m e L a s t N a m e C i t y P h o n e N u m b e r S h i v a R a m a Myso re 08212569964P r a t a p S B a n g alo re 08025689754S r e e n i v a s G Merc a r a 08965445454

<html> <head>

Page 19: 5th sem prct solution for NIIT kuvempu University

</head> <tittle> Data Table </title> <body> <table border=1> <tr> <th>First Name</th> <th>Last Name</th> <th>City</th> <th>Phone Number</th> <tr> <tr> <td>Shiva</td> <td>Rama</td> <td>Mysore</td> <td>08212569964</td> </tr> <tr> <td>Pratap</td> <td>S</td> <td>Bangalore</td> <td>08025689754</td> </tr> <tr> <td>Shrinivas</td> <td>G</td> <td>Mercara</td> <td>08965445454</td> </tr> </table> </body></html> 

S e t 13

Page 20: 5th sem prct solution for NIIT kuvempu University

//1. W r i te C P r og r a m t o c re a te In di a n F l a g.

#include<stdio.h>#include<conio.h>#include<math.h>#include<graphics.h>const float PI=3 .14154;void main(){int gdriver=DETECT,gmode=0;int I;Int x,y;initgraph(&gdriver,&gmode,"c:\\tc\\bgi");cleardevice();rectangle(0,0,63 9,479);outtextxy(250,20,"INDIAN FLAG");rectangle(80,50,560,3 80);line(80,160,560,160);line(80,270,560,270);setfillstyle(SOLID_FILL,LIGHTRED);floodfill(85,60,getmaxcolor());setfillstyle(SOLID_FILL,WHITE);floodfill(85,170,getmaxcolor());setfillstyle(SOLID_FILL,GREEN);floodfill(85,280,getmaxcolor());setcolor(BLUE);circle(3 20,215,50);for(I=0;I<=3 60;I+=15){x=50*cos(I*PI/180);y=50*sin(I*PI/180);line(3 20,215,3 20+x,215-y);}setcolor(CYAN);settextstyle(TRIPLEX_FONT,HORIZ_DIR,6);

Page 21: 5th sem prct solution for NIIT kuvempu University

outtextxy(200,400," JAI HIND!!!" ) ;getch();}

//2. W r i te C P r og r a m t o c re a te F I S H s t r u c t u r e u s i n g b a s ic geo m e t r ic F u n c tio n s.

#include<graphics.h>#include<stdlib.h>#include<conio.h>#include<dos.h>

void main(){ int gd=DETECT,gm,i,j,p,q,x,y,k,flag; struct arccoordstype arcinfo; initgraph(&gd,&gm,"c:\\tc\\bgi"); y=getmaxy()/2; i=0; p=0; q=0; j=0; flag=0; setcolor(WHITE); for(k=0;k<500;k++) putpixel(random(620),random(419),15); while(!kbhit()) { line(0+i,y+20,0+i,y-20); /*triangle*/ line(0+i,y+20,20+i,y); line(0+i,y-20,20+i,y);

ellipse(80+i,y,10-p,3 50+p,60,25); line(140+i,y+3 ,13 0+i,y+8); line(13 0+i,y+8,140+i,y-5);

Page 22: 5th sem prct solution for NIIT kuvempu University

if(flag==0) p=p+2; if(flag==1) p=p-2;

circle(120+i,y-6,5);

line(60+i,y-25,3 0+i,y-45+j); line(3 0+i,y-45+j,100+i,y-25); line(60+i,y+25,3 0+i,y+45+q); line(3 0+i,y+45+q,100+i,y+25); i=i+3 ; if(i>=63 8) i=0;

if(flag==0) j=j-2,q=q+2;

if(flag==1) j=j+2,q=q-2;

if(j<=-10) flag=1; else if(j>=0) flag=0;

delay(10); cleardevice(); } getch(); closegraph();} 

S e t 14

Page 23: 5th sem prct solution for NIIT kuvempu University

//1. W r i te Ope n G L P r og r a m t o c re a t e a W i n d o w a n d dis pl ay H E L L O in side.

#include<GL/glut.h>void display(void){ glClear(GL_COLOR_BUFFER_BIT); glColor3 f(1.0,1.0,1.0); glBegin(GL_POLYGON); glVertex3 f(0.25,0.25,0.25); glVertex3 f(0.75,0.25,0.0); glVertex3 f(0.75,0.75,0.0); glVertex3 f(0.25,0.75,0.0); glEnd(); glFlush();

}

Void init(void){ glClearColor(0.0,0.0,0.0,0.0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0,1.0,0.0,1.0,-1.0,1.0);}

Int main(int argc,char**argv){ glutInit(&argc,argv); glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(250,250); glutInitWindowPosition(100,100); glutCreateWindow(“HELLO”); init();glutDisplayFunc(display);glutMainLoop();

Page 24: 5th sem prct solution for NIIT kuvempu University

return 0;}

//2. C r e a t e a s i m p le s t a t ic w e b p a ge f o r a college ( a s s u m e n ece s s a r y in fo r m a t io n )

<html><head><title>My College Site</title></head><body bgcolor="gray" text="white" ><div id="banner" style="width:800px; height:120px; background-color:black"><img src="file:///C:/banner.gif" width=800 height=120></div><div id="header" style="position:absolute; left:100px; top:3 0px; width:3 50px; height:75px"><div><h1><font color="red" face="Monotype corsiva">My College Site</font></h1></div></div><div id="header" style="position:absolute; background-color:black; top:13 5px; width:200px; height:500px"><ul id="listitem" type="circle"><li><a href=abc.html target="_self">Home</a></li><li><a href="Sitemap.html">Sitemap<a></li><li><a href="About.html">About Us<a></li></ul></div><div id="header" style="position:absolute; background-color:black; left:215px; top:13 5px; width:590px; height:500px"><h3 ><font color="red">Online Admission</font></h3 ><form id="frm1">Enter your name: <input type="text" id="text1" /> <br/><br/>Gender: <input type="radio" id="gender1" name="gend" />Male <input type="radio" id="gender1" name="gend" />Female <br/><br/>Qualification: Matric<input type="checkbox" id="check1" /> Enter<input type="checkbox" id="check1" /><br/><br/><input type="reset" value="Reset" /><input type="submit" value="Submit" post="" /><br/><br/>

Page 25: 5th sem prct solution for NIIT kuvempu University

</form></div></body></html>