Saturday 11 May 2013

COMPUTER GRAPHICS QUESTION PRACTICE AND QUESTION PAPERS

Q.1
a.Discuss atleast four applications of computer graphics.
b.When are Orthographic and Perspective projections at their best?
c.Define Lambertian reflectors. What is diffuse - reflection coefficient? What is its value?
d.Differentiate between Object Space and Image Space Methods for visible surface detection. Which is more common?
e.Mention any fourproperties of B-spline curves.
f.Prove that two successive 2D-rotations are additive, i.e. R (θ1) R (θ2) =R (θ1+ θ2).
g.What kind of clipping windows cannot be handled by Cyrus-Beck clipping algorithm? How such cases are handled?(7×4)

Q.2
a.Write a note on RGB cube. What are two ways
by which you can specify color in computer graphics?(8)
b.How do you identify a concave polygon? Describe two methods for splitting concave polygons using proper diagrams.(10)

Q.3
a.Show that the order in which transformations are performed is important by applying the transformation of the triangle ABC by:
(i)Rotating by 45o about the origin and then translating in the direction of the vector (1,0), and
(ii)Translating first in the direction of the vector (1,0), and then rotating by 45o about the origin, where A = (1, 0) B = (0 ,1) and C = (1, 1). (9)
b.Suppose a rectangular window ABCD is defined such that A (-1,-2) and C (3, 1).Using Cohen-Sutherland algorithm, clip the line segment joining the points P (-20, 0)
and Q (20, 30). Discuss limitations of Cohen-Sutherland algorithm.(9)

Q.4
a.Write a brief note on Koch curve and the creation of different order of Koch curves.(6)
b.Briefly describe:
(i)Horner’s rule
(ii) Forward difference calculation.(6)
c.Write openGL curve functions, line functions and Geometric transformation functions; two from each category with their meaning.(6)

Q.5
a.What are the fundamental operations involved in projecting a 3D point to a 2D pointon a Plane. Taking a suitable example explain one, two and three point perspective
projections.(10)
b.Write a brief note on CSG methods. Give an example to illustrate.(8)

Q.6
a.Discuss Depth sorting method for hidden surface elimination. What tests are performed when there is depth overlap ?(9)
b.To render a polygon, how does Gouraud surface rendering and Phong surface rendering proceed? Explain briefly. Also discuss problems with Gouraud Shading.(9)
Q.7
a.What are two basic properties a fractal object has? Define with examples the three groups of fractals.(9)
b.How do you determine dimension of an object using fractal dimension method?Explain giving an example.

Q.7
a.Investigate the effect of translation with tx=2, ty=3 followed by scaling with sx=2, sy=3 on the line AB with A(0,0) and B(1,1)
b.Describe the DDA line drawing algorithm.
c.Briefly describe the Cohen -Sutherland line clipping algorithm.
d.Write a short note on Morphing.
e.What do you understand by self-similar and self-affine fractals?
f.What are homogeneous co -ordinates? How are they used in matrix representation of transformations?
g. Briefly explain the binary space -partitioning method.(7×4)

Q.8
a.
Explain the Constructive Solid Geometry(CSG) method for solid modeling. Briefly explain how ray - casting methods are used to implement CSG operations.(9)
b.What are Octrees and why are they useful? How are they implemented? (9)

Q.9
a.Explain the Z-Buffer method of Hidden Surface removal.(9)
b.Explain the Depth-sorting method for the elimination of Hidden surfaces. What are the basic functions it performs?(9)

Q.10
a.Calculate the pixel colour value at the centroid of the triangle as shown below. The figure shows the coordinates and the colour of the vertices of the triangle. Use The Gouraud interpolation technique for interpolation.(10)

b.Explain the Phong shading model for rendering of polygon surfaces.(8)
Q.5
a.Explain how Bresenham’s Line Algorithm is used to create accurate and efficient raster lines.(9)
b. Why do we need to antialias eour output? How is it done?(9)

Q.11
a.Write the matrix of:
(i)Rotation through theta degrees in the counter clockwise direction
(ii)Reflection in x-axis
(iii) Reflection in y-axis(9)
b.Investigate the effect of reflection in x-axis followed by rotation through 45 degrees followed by reflection in y-axis on the square A(0,0), B(0,1), C(1,1), D(1,0).(9)


Q.12
a.Find the equation of the Bezier curve that passes through (0, 0) and (4, 2) and controlled through (14, 10) and (4, 0).(6)
b.What are B-spline curves? Explain briefly mentioning a few of their properties.(6)
c.Enumerate the major differences between Bezier curve, B- spline curves and B- spline curve-NURBS.




ANNA UNIVERSITY OF TECHNOLOGY, COIMBATORE
B.E. / B.TECH. DEGREE EXAMINATIONS: NOV / DEC 2011
REGULATIONS: 2008
SIXTH SEMESTER: CSE
080230030 - COMPUTER GRAPHICS
Time: 3 Hours
PART - A
ANSWER ALL QUESTIONS
Max. Marks: 100
(10 x 2 = 20 Marks)
1. Differentiate between Random Scan and Raster Scan displays
2. What is scan conversion?
3 What do you mean by aspect ratio?
4 Can you use line clipping algorithm to clip a polygon? Justify
5 What do you mean by Shearing?
6 What is a vanishing point?
7 What is a viewing pipeline?
8. What are the steps in rotating a triangle ABC by an angle e with respect
to an arbitrary point P?
9. Define Illumination.
10. What are the various applications of Computer graphics?

PART – B (5 x 16 = 80 Marks)
ANSWER ALL QUESTIONS

11. (a) Explain about Cathode Ray Tube in detail
(OR)
(b) Explain Cohen Sutherland's line clipping algorithm with an example
12. (a) Scale the triangle with vertices A(O,O), B(1,1), c(5,2) to twice its size along Xaxis
and to half its size along Y-axis.
(OR)
(b) Rotate the above triangle ABC by 90 degrees with respect to the point C (5,2).
13 (a) Explain in detail the three-dimensional transformations (Translation, Scaling, and
Rotation) giving their matrix representations
(OR)
(b) What are the methods involved in projecting three dimensional objects on a two
dimensional view plane? Explain
14. (a) List down the various visible surface detection algorithms and explain any two in detail.
(OR)
(b) Compare the various representation methods for solids.
15. (a) Discuss the Illumination and shading models for polygons.
(OR)
(b) Explain the OpenGL features for graphics programming.

*****THE END*****


ANNA UNIVERSITY OF TECHNOLOGY, COIMBATORE
B.E. / B.TECH. DEGREE EXAMINATIONS
COMPUTER GRAPHICS
Answer ALL questions.
PART A - (10 x 2 = 20 marks)

1. What are the merits and demerits of plasma panel display?
2. Define true color systems.
3. What are the limitations of DDA algorithm?
4. State few attributes of Curves.
5. What is homogenous coordinates?
6. Distinguish Clipping and Culling.
7. Define Blending Functions.
8. What is the use of View Reference point?
9. Define the roles of Coherence.
10. Define Virtual Reality.

PART B - (5 x 16 - 80 marks)
11. (a) Explain the principle of following video display devices:
(i) Cathode Ray Tube. (8)
(ii) Liquid Crystal Displays'. (8)
Or
(b) Describe the working methodology of various input devices used for developing graphics applications.
12. (a) Explain the Bresenham's line drawing algorithms and analyze its merits  and demerits.
Or
(b) Describe the procedure to generate a ellipse and show how it differs from circle drawing algorithms.
13. (a) Explain how to achieve the key two dimensional transformations using suitable examples.
Or
(b) Explain the polygon clipping with the help of Sutherland - Hodgeman algorithm.
14. (a) Explain how to generate a Bezier Curve using the blending functions.
Or
(b) Discuss the methodology of perspective projection and describe how it can be expressed using homogeneous coordinates.
15. (a) Explain the concept of Depth Buffer algorithm for detecting visual surface of a 3D object.
Or
(b) Discuss the important principles behind Computer Animation with suitable diagrams.


 Answer ALL questions.
PARTA-- (10 x 2 = 20 marks)
1. What is true color system?
2. Differentiate positive matrix from active matrix.
3. Explain the disadvantages of DDA line drawing algorithm.
4. Explain how to load intensity values into the address of the frame buffer.
5. What is affine transformations?
6. Define view up vector.
7. How many control points are required to influence each section of spline curve? (between two successive knot values)
8. What is center of projection?
9. What is ray casting?
10. Define morphing.

PART B __ (5 x 16 = 80 marks)
11. (a) List the operating characteristics technologies : for the following display
(4 x 4 = 16)
(i) Raster refresh system .
(ii) Vector refresh system
(iii) Plasma panels
(iv) LCD.
Or
(b) (i) Explain how Raster scan. system works. (8)
(ii) Discuss the use of computer graphics in computer aided design. (8)
12. (a) Explain the basic concept of Midpoint circle algorithm. Derive the
decision parameter for the algorithm and write down the algorithm
steps. (16)
Or
(b) (i) Briefly explain the line attributes. (8)
(ii) Write short notes on antialiasing. (8)
13. (a) (i) Prove that the multiplication of transformation matrices for each of
the following sequence of operations is commutative: (8)
(1) Two successive rotation
(2) Two successive translation.
(ii) Explain with region codes the operation of Cohen Sutherland line
clipping algorithm. (8)
Or
(b) Define clipping. Explain Sutherland Hodgeman polygon clipping.
What is the deficiency of it? How is it rectified with the other
algorithm? (2 + 8 + 3 + 3)
14. (a) Determine the blending function for uniform periodic Bspline curves for
n = 3, d = 2. (16)
Or
(b) Explain 3D basic transformations with an example. (16)
15. (a) What are the classification of visible surface detection methods? Explain
anyone algorithm in each category. (16)
Or
 (b) (i) Design a story board layout and accompanying key frames for an
animation of a given object. How do. You give acceleration for the
same objects? (8)
(ii) Explain the prineiples of animation

OPEN SOURCE LAB MANUAL



LIST OF EXPERIMENTS

S.NO.
TITLE OF THE EXPERIMENT
PAGE NO.
1.
INSTALLATION  OF LINUX IN DIFFERENT MODES
3
2.
MYSQL INSTALLATION
27
3.
APACHE INSTALLATION
30
4.
PHP WITH DATABASE CONNECTIVITY
38
5.
PHYTON PROGRAMMING
46
6.
PERL PROGRAMMING
51
7.
NETWORK SIMULATOR (NS2) INSTALLATION
565











Ex.NO : 1                     INSTALLATION OF LINUX IN VARIOUS MODES
AIM:
To write a procedure for PC Boot and Linux init process.

PROCEDURE:
INTRODUCTION TO OPEN SOURCE SOFTWARE:


Open-source software (OSS) is computer software that is available in source code form for which the source code and certain other rights normally reserved for copyright holders are provided under a software license that permits users to study, change, and improve the software. Open source licenses meet the requirements of the  Open Source Definition. Some open source software is available within the public  domain.  Open  source  software  is  very  often  developed  in  a  public, collaborative manner. Open-source software is the most  prominent example of open-source  development  and  often  compared  to  (technically  defined)  user- generated  content or (legally defined) open content movements. The term open- source software originated as part of a marketing campaign for free software.

POPULAR DISTRIBUTIONS:

Well-known Linux distributions include:
CentOS, a distribution derived from the same sources used by Red Hat, maintained by a dedicated volunteer community of developers with both
100% Red Hat-compatible versions and an upgraded version that is not always 100% upstream compatible
Debian, a non-commercial distribution maintained by a volunteer developer community with a strong commitment to free software principles
Linux Mint, a distribution based on and compatible with Ubuntu.

Mandriva,  a  Red  Hat  derivative  popular  in  France  and  Brazil,  today maintained by the French company of the same name.
openSUSE a community distribution mainly sponsored by Novell.

Oracle Enterprise Linux, which is a derivative of Red Hat Enterprise Linux, maintained and commercially supported by Oracle.
PCLinuxOS, a derivative of Mandriva, grew from a group of packages into a community-spawned desktop distribution.


Red Hat Enterprise Linux, which is a derivative of Fedora, maintained and commercially supported by Red Hat.
Slackware, one of the first Linux distributions, founded in 1993, and since then actively maintained by Patrick J. Volkerding.
Ubuntu, a popular desktop and server distribution derived from Debian, maintained by Canonical Ltd..
Xubuntu,  is  the  Xfce  version  of  the  popular  desktop  distro  Ubuntu. Commonly used by Linux users that wish to have the function of a bigger distro such as Ubuntu or openSuse with the speed of a smaller distribution.

INTRODUCTION TO LINUX OPERATING SYSTEM


Linux refers to the family of Unix-like computer operating systems using the Linux kernel. Linux can be  installed on a wide variety of computer  hardware, ranging  from  mobile  phones,  tablet  computers  and  video  game  consoles,  to mainframes and supercomputers. Linux is a leading server operating system, and runs the 10  fastest supercomputers in the world. Use of Linux by end-users or consumers has increased in recent years,  partly owing to the popular  Ubuntu, Fedora, and openSUSE distributions and the emergence of net books with pre- installed Linux systems and smart phones running embedded Linux.

The development of Linux is one of the most prominent examples of open collaboration; typically all the underlying source code can be used, freely modified, and redistributed, both commercially and  non-commercially, by anyone under licenses such as the GNU General Public License. Typically Linux is packaged  in a format known as a Linux distribution for desktop and server use. Linux distributions include the Linux  kernel  and all of the supporting software required to run a complete system, such as utilities and libraries, the X Window System, the GNOME and KDE desktop environments, and the Apache HTTP Server.  Commonly  used  applications  with  desktop  Linux  systems  include  the Mozilla Firefox web-browser, the OpenOffice.org office application suite and the GIMP image editor.
The name "Linux" comes from the Linux kernel, originally written in 1991 by Linus Torvalds.
















STANDARD INSTALLATION OF FEDORA 14


Fedora  is an  RPM-based, general  purpose collection  of software including an operating  system  based  on  the  Linux  kernel,  developed  by  the  community- supported Fedora Project and sponsored by Red Hat. The Fedora Project's mission is to lead the advancement of free and open source software and content as a collaborative community.

One of Fedora's main objectives is not only to contain software distributed under a free  and  open  source  license,  but  also  to  be  on  the  leading  edge  of  such technologies.  Fedora  developers  prefer  to  make  upstream  changes  instead  of applying fixes specifically for Fedora—this ensures that their updates are available to  all Linux distributions. In 2008, Linus Torvalds, author of the Linux kernel, started that he used Fedora because  it had fairly good support for the PowerPC processor architecture which he favored at the time.
Basic Installation Steps:


1.  Boot from the DVD.



2.  Skip the media test by pressing the tab and return keys on the

keyboard.





















3.  Click the "Next" button on the welcome screen.















4.  Select the appropriate language, then click the "Next" button.






















5.  Select the appropriate keyboard layout, then click the "Next" button.








6.  When prompted, click the "Re-initialize drive" button.






7.  When prompted, click the "Re-initialize" button.
8.  Enter a fully qualified hostname, then click the "Next" button.









9.  Select the appropriate timezone by clicking on the nearest city on the

map, then click the "Next" button.












10. Enter the root password, then click the "Next" button.

















11. Select the "Use All Space" option, uncheck the "Encrypt system" option and check the "Review and modify partitioning layout" option,
then click the "Next" button.










12. The current partitioning layout is presented. If the OS is to be used for an Oracle installation,  make sure the swap partition is at least 2G (2048M) in size. Once you are happy with the partition structure, click
the "Next" button followed by the "Format" and "Write changes to
               disk"button.



13. Select the appropriate packages to install and check all three

Additional repositories.








.

15. Selecting the repositories will require you to enter your network configuration. Select the appropriate network interface, highlight the "System eth0" adapter and click the "Edit" button. Click on the the "IPv4 Settings" tab, select the appropriate method and enter the required information. When complete, click the "Apply" and "Close"
         buttons




16. Once the repositories are selected, select the "Customize Now" option

and click the "Next" button.










17. Select the appropriate package groups and optional packages for your

installation and click the "Next" button.








18. Wait while the installation completes.








19. When the installation is complete, restart the machine as instructed.
When the machine has restarted, click the "Forward" button on the welcome screen.




20. Accept the license agreement by clicking the "Forward" button.
















21. Enter login user details, then click the "Forward" button.



















22. Set the appropriate date-time information, then click the "Forward"

button.













23. Decide if you want to send a hardware profile to the Fedora project,

then click the "Finish" button.












24. Click the username you defined previously.




25. Enter the password and click the "Log In" button.







26. After you've logged in, you are presented with the default Fedora

desktop.
































RESULT:
Thus the Linux Operating System is installed successfully.

Ex.NO : 2                           INSTALLATION OF MYSQL
AIM:
To Write a procedure for installing MySQL on Linux Operating System.
PROCEDURE
MYSQL INSTALLATION

……………………………………………………

[root@server root]# cd /root

[root@server root]# mkdir /root/files /data /data/mysql

[root@server root]# cd files


4.0.12.tar.gz

[root@server root]# tar xzvf mysql-4.0.12.tar.gz

[root@server root]# cd mysql-4.0.12
if your using FreeBSD use "adduser" instead of "useradd". [root@server root]# groupadd mysql
[root@server root]# useradd -g mysql mysql

[root@server root]# ./configure --prefix=/usr/local/mysql

--datadir=/data/mysql

DataDir is where your mysql databases will be stored including the database which contains all mysql user accounts,
you can easily backup all databases/users by saving the contents of this folder. /data/mysql
NOTE: If you see ERROR: No curses/termcap library found" find where libncurses.so.5 is installed on your system and add the following flag to your configure statement : --with-named-curses-libs=/usr/lib/libncurses.so.5 (or
where ever it may be)

if you get a "mod_auth_dbm" Error

Copy the ndbm.h file from /usr/include to the /usr/include/db1 directory (or install db1-devel)
if you get a "no acceptable C compiler found in $PATH" Error

Install a c compiler, example: gcc




if you get "libmysql.c:1349: warning: passing arg 5 of `gethostbyname_r' from incompatible pointer type" Error
you need to install a c++ compiler, install: libstdc++-devel, gcc-c++ (same version as gcc)
[root@server root]# make

[root@server root]# make install

[root@server root]# ./scripts/mysql_install_db

[root@server root]# ln -s /usr/local/mysql/share/mysql/mysql.server

/sbin/mysqld

[root@server root]# chown -R mysql:mysql /data/mysql

[root@server root]# chown -R mysql:mysql /usr/local/mysql

Start, Stop & Restart MySQL

---------------------------------------- [root@serverroot]# mysqld start [root@serverroot]# mysqld stop
[root@server root]# mysqld restart

Using MySQL

----------------------------------------

Export Database:

[root@server root]# /usr/local/mysql/bin/mysqldump -u root -p database_name > database_name.sql


Import Database:

[root@server root]# /usr/local/mysql/bin/mysql -u root -p database_name <

database_name.sql



Set root password:

[root@server root]# /usr/local/mysql/bin/mysqladmin -u root -p password

NEW_PASS


NOTE: When it prompts you to enter the password, just hit Enter if you don't see an error, the password was successfully changed.




Uninstalling MySQL

---------------------------------------- [root@server root]# rm -rf /usr/local/mysql [root@server root]# rm -rf /data/mysql
[root@server root]# rm -rf /sbin/mysqld



































RESULT:
Thus the MySQL is installed in Linux Operating System successfully.
EX.No: 3                                         APACHE INSTALLATION

AIM :
 To write a procedure to install Apache Server in Linux Operating system.

APACHE INSTALLATION:
Introduction

The Apache Web server is arguably the most popular Web server in use on the Internet today. Here are some of the reasons why Apache is so popular; you don't have to be running Windows to run Apache. It was developed on various  Unix/Linux/BSD  platforms,  and  then  recently  ported  to  Win32. Internet  Information  Server,  a  Web  server  made  by  Microsoft  for  the Windows NT platform, is made for use in the "Windows-only" world. While IIS has many features, its lack of portability limits its market share.
Another reason for Apache's widespread acceptance is its overall stability. While you can slow down an Apache Web server, you can rarely, if ever, kill one. The Apache Web server service is  near  bulletproof. Lastly, it's relatively fast. I say "relatively" as it's relative to what you're doing with it. If you're hosting a pretty plain Web site with mostly static content, Apache is a fireball. If you throw tons of CGI scripts at it, while making database calls at the same time, you're going to slow it down. Though much of the slowdown will come from your scripts themselves, and not from Apache. Apache evolved out of the NCSA https project to its current status as one of the fastest, most efficient, and most  functional web servers in existence today.
Apache has been shown to be substantially faster, more stable, and more feature-full  than  many  other  web  servers.  Although  certain  commercial
servers    have    claimed    to    surpass   Apache's    speed   (it     has   not    been demonstrated that any of these "benchmarks" are a good way of


measuring WWW server speed at any rate). The developers of Apache feel that it is better to have a mostly-fast free server than an extremely fast server that costs thousands of dollars. Apache is run on sites that get millions of hits per day, and they have experienced no performance difficulties. Apache is  run on

over 10 million Internet servers (as of May 2002). It has been tested  thoroughly  by  both   developers  and  users.  The  Apache  Group maintains rigorous standards before releasing new versions of their server, and their server runs without problems on over one half of all WWW servers available on the Internet. When bugs do show up, they release patches and new versions as soon as they are available.
Installation Options

Ill cover three methods of installing Apache under Linux. The three methods are:
·Binary installation
·Using an RPM (Red Hat Package Manager) recommended for people running Red Hat Linux
·Building from source



Apache Installation Guide
We recommend using the RPM installation method. This is the easiest way to install Apache for people that are new to Linux.
Download the Software

You can download Apache from the Apache Software Foundation web site located at
http://www.apache.org, in source and binary forms. While your downloading Apache, you may
want to browse over the documentation.
What you need
To install Apache, you will need the following things:

1. A computer running Linux

2. Root access on this computer

3. For binary and source installations, the tar and gunzip Unix utilities


Binary Installation

A binary is pre-configured, which means someone else has gone to the trouble  of  configuring  and   building  the  software  for  you.  There  are, however, a few things you should keep in mind:
1. Binaries are compiled for a particular operating system. In other words, you must use a binary  built  specifically for FreeBSD on your FreeBSD
machine and a Linux binary on your Linux machine. You need to be sure to grab the correct binary; if you don't see a binary for your particular operating system, you must choose a different method of installation.

2. Apache binaries are usually a version or two behind the current source distribution. This means you don't reap the benefits of the latest bug fixes and feature enhancements.
3. Because binaries are pre-configured, you don't have much opportunity to alter the way the software works. If you're a newcomer, you may not care about this loss of flexibility. Fortunately most Apache binaries include a full source distribution, providing you with the best of both worlds -- play now, learn later.

Now let's install a binary. Point your browser at


and download the binary for your operating system (in our case, Linux). You'll most likely be presented with a directory containing multiple versions of Apache in various compressed forms. For the purposes of this guide, I'll assume you've downloaded the gzip'd form of the latest 2.0.x Apache binary (currently that's httpd-2.0.35-i686-pc-linux-rh72.tar.gz). If there is a README associated with the file you're downloading, you may want to review it for any interesting installation tidbits or possible bugs.
If you can't find a binary for your operating system, choose either the RPM Installation  (if  you  are  running  Red  Hat  Linux)  or  Build  from  Source
method. Now let's uncompress the archive using the handy combination of gunzip and  tar.  You  should  replace  the          "httpd-2.0.35-i686-pc-linux- rh72.tar.gz" text below with the name of the gzip'd file you downloaded.

gunzip < httpd-2.0.35-i686-pc-linux-rh72.tar.gz | tar xvf

Some of you may be lucky enough to have a version of tar that is capable of taking care of both tasks.
tar xvzf httpd-2.0.35-i686-pc-linux-rh72.tar.gz

Either way, you should end up with an httpd-2.0.x directory, with x being the particular subversion of Apache you downloaded. Move into the newly created directory.
cd httpd-2.0.x

As of Apache 1.3.11, binary distributions contain an install script called install.bindist.sh. If your  binary does not seem to contain such an install script,  take  a  look  at  the  README.bindist  and/or   INSTALL.bindist documents for further information; if these documents don't outline a simple installation method, you'll probably want to use one of the other methods I cover in this guide.
If you've not already done so, you'll need to become root. You can become root by typing su, then the root password. Then go ahead and run the install
script.

./install.bindist.sh
This command should install the various bits of the Apache distribution into the appropriate locations; the default is usually to install everything under
/usr/local/apache (confirm this by consulting your README.bindist and/or

INSTALL.bindist documents). That's all there is to it on installing binaries.

RPM Installation

Those of you running Red Hat Linux may want to take advantage of Red Hat's RPM ("RedHat Package Manager") system. Almost identical to a binary, an RPM is further customized to play nicely with other RPMs and provide a consistent interface to installing, updating, and removing binaries. For Linux newcomers or when installing a small standard component, RPMs are simple and reliable.  Bear in mind that an Apache RPM may already be installed on your system depending on how Linux was originally installed on your computer. To find out, at the shell prompt, type:
rpm -qa | grep apache

If you see something like apache-1.3.9xxx, an Apache RPM has already been installed. You can also  type that command typing httpd instead of apache to see if its installed. If you don't have an Apache RPM, you must obtain    one.      Red                         Hat                  7.3 ships        apache-1.3.23-                11.src.rpm     in        the RedHat/RPMS directory on the installation CD. Or, point your browser at ftp://ftp.redhat.com/pub/redhat/redhat-7.3-en/os/i386/RedHat/RPMS            and download it. If you've not already done so, you'll need to become root.
Navigate to the same directory as the .rpm file you obtained, and then type the following command, substituting the name of the .rpm you're using for example: apache-1.3.23-11.src.rpm.

rpm -ivh apache-1.3.23-11.src.rpm

RPM should grind away, displaying its progress with a primitive #######

progress bar. Barring any errors, you're done.
Build from Source

Building Apache from source may seem like a daunting task to newcomers, but the Apache developers  have done a wonderful job of making the task about  as  simple  as  could  be.  Just  three  more  commands  than  a  binary installation and you skip the arduous task of figuring out which binary is the right  one  for  your  particular  operating  system.  Point  your  browser  at http://www.apache.org/dist/httpd/  and  download  the  gzip'd  form  of  the current version of Apache  (2.0.36 at the time of this writing). Now let's uncompress that archive using gunzip and tar. You should replace the httpd-
2.0.36.tar.gz below with the name of the gzip'd file you downloaded.

gunzip < httpd-2.0.36.tar.gz | tar xvf –


You should end up with an httpd-2.0.x directory, x being the particular sub- version of Apache you downloaded. Move into the newly created directory.

cd httpd-2.0.x

Now we'll use the the configure and make commands to configure, make, and install Apache. If you've not already done so, now would be the time to become root.
./configure

Your screen should look something like:



# ./configure

checking for chosen layout... Apache checking for working mkdir -p... yes
checking build system type... i686-pc-linux-gnu checking host system type... i686-pc-linux-gnu checking target system type... i686-pc-linux-gnu Configuring Apache Portable Runtime library ......

config.status: executing default commands

Unless errors were reported (not warnings), your Apache installation is now configured and we can move on. This is where things get a bit ugly. Make'ing Apache produces screenfulls of output.
Make

Your screen should look something like:

# make

Making all in srclib

make[1]: Entering directory `/home/ryan/dl/apache_guide/httpd-
2.0.36/srclib' Making all in apr

make[2]: Entering directory `/home/ryan/dl/apache_guide/httpd-

2.0.36/srclib/apr'...

make[1]: Leaving directory `/home/ryan/dl/apache_guide/httpd-2.0.36'#

Finally, you're ready to install your Apache build.

# make install

Now Apache is installed.


Starting Apache
Let's take your new Apache installation out for a spin.

If you installed Apache using a binary or from scratch, as root, type:

/usr/local/apache/bin/apachectl start

If you used an RPM, as root, type:

/sbin/service httpd start

Point your browser at your brand new Web server, http://localhost/. If everything worked you should see the default home page.
Customize
Apache uses some rather easy to understand text files for configuration. On a Red Hat system,you'll find them in /etc/httpd/conf. Quite a few Linux
distributions place them in this same place, but if you can't find such a directory, do a search for "httpd.conf". Once you find these, you've
found the main config files. If you're new to Linux, and need help finding this file, here's how you can find it.
1.Login as root

2.Type: cd /

3.Type: find -name httpd.conf


Now you should see where the file is located. When you move into the directory containing
httpd.conf, you should see these three files:

·httpd.conf This has the settings for the overall configuration for the server.
·access.conf This file contains all the security settings for Apache.

·srm.conf This file contains the MIME definitions and default document names for files on the server












































RESULT:
Thus the Apache Server is installed in Linux Operating System successfully.


EX.NO:4                                    PHP WITH DATABASE CONNECTIVITY
AIM:
To create a simple web page using PHP and MySQL database connectivity.

PROCEDURE:
type the following in gedit and save it as form.html

<html>

<head>

<title>LOGIN</title></head>

<body>

<form action="connect.php" method="post">

<p>

"Enter course no"<input type="text" name="cid"></p>

<p>"enter the coursename"<input type="text" name="cname"></p>

<p>"click here to submit"<input type="submit" name="submit"></p>

</form>

</body>
Type the following in gedit and save it as connect.php
<?php

$cid=$_POST['cid'];

$cname=$_POST['cname'];

$con=@mysql_connect("localhost","root","")or die (mysql-error());

echo "connected to database";

$db=@mysql_select_db("student",$con)or die(mysql_error());

echo "selected database";

$str="insert into courses values($cid,'$cname')";

$res=@mysql_query($str) or die(mysql_error());

if($res>0)

{

echo "Record created";

}

?>

TYPE THE FOLLOWING IN THE BROWSER


























When press the submit button








now go to terminal



[linuxpert@localhost ~]$ mysql -u root -p\

> > Enter password:



Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 28
Server version: 5.1.45 Source distributionmysql> show databases;

+--------------------+

| Database             |

+--------------------+

| information_schema |

| mysql                 |

| student              |

| test                  |

+--------------------+

4 rows in set (0.11 sec)


mysql> use student ;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A Database changed
mysql> connect

Connection id:      29

Current database: student


mysql> show tables;

+-------------------+

| Tables_in_student |

+-------------------+

| course              |
| courses             |

| students            |

+-------------------+

3 rows in set (0.00 sec)

mysql> select * from courses;

+------+-------+

| cid  | cname |

+------+-------+

|    1 | java  |

|    1 | java  |

+------+-------+

2 rows in set (0.02 sec)



2. Create                    Login Page



Create Login Page (HomePage.php)


<table width="300" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#CCCCCC">
<tr>

<form name="form1" method="post" action="checklogin.php">

<td>

<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#FFFFFF">
<tr>

<td colspan="3"><strong>Member Login </strong></td>




</tr>

<tr>

<td width="78">Username</td>

<td width="6">:</td>

<td width="294"><input name="myusername" type="text" id="myusername"></td>
</tr>

<tr>

<td>Password</td>

<td>:</td>

<td><input name="mypassword" type="text" id="mypassword"></td>

</tr>

<tr>



<td>&nbsp;</td>

<td>&nbsp;</td>

<td><input type="submit" name="Submit" value="Login"></td>

</tr>

</table>

</td>

</form>

</tr>

</table>
Create Validation Page (checklogin.php)



<?php




$host="localhost"; // Host name

$username="root"; // Mysql default username

//$password=""; // Mysql No password

$db_name="my_db"; // Database name

$tbl_name="members"; // Table name

// Connect to server and select databse.

mysql_connect("$host", "$username")or die("cannot connect");

mysql_select_db("$db_name")or die("cannot select DB");

// username and password sent from form

$myusername=$_POST['myusername'];

$mypassword=$_POST['mypassword'];

$sql="SELECT * FROM $tbl_name WHERE

username='$myusername' and password='$mypassword'";

$result=mysql_query($sql);

// Mysql_num_row is counting table row

$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
if($count==1)




echo "Welcome To Our Web Page";


else



?>









 
echo "Wrong Username or Password";


























































RESULT:
Thus the program executed successfully

EX.NO:5                                            PHYTON PROGRAMMING

AIM:
To write various programs in PYTHON.

1. Write a Hello World Python Program

.#!/usr/bin/python


print "Hello World!";


2. String Concatenation in python programming

#String concatenation worda='computer'; wordb='science'; print("worda is ",worda); print("wordb is",wordb); wordc=worda+" " +wordb; print("wordc is",wordc); wordd=worda*3; print("wordd is ",wordd); str = 'HelloWorld!' length=len(str);
print ("str :",str);
print("length:",length);
print ("first character is",str[0]);
print ("print character from 2rd to 6th :", str[2:7]              ); print ("Prints string starting from 3rd character:",str[2:]); print ("Prints string two times",str * 2);
print ("Prints concatenated string :",str + "TEST" );
print(str[-1]); #print last character
print(str[-6]);#print character from last 6th position print(str[:-2]);# Everything except the last two characters.

3. Write a python program to perform function in Lists


#Python Lists
#!/usr/bin/python
print("\t \t \t Python Lists");
list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]
tinylist = [123, 'john']

print("Prints complete list:",list);
print("Prints first element of the list : ",list[0]);
print("Prints elements starting from 2nd to 4th:",list[1:3]); print("Prints elements starting from 3rd element:",list[2:]); print("Prints list two times:",tinylist * 2);
print("Prints concatenated lists: ", list + tinylist );

#modify the 4th elements in the list
print("Before modifying the 4th element in list :",list[4]);
list[4]='efgh';
print("4th element in list :",list[4]);
print(" complete list:",list);

#Appending new elements
list.append('ijkl');
print("After appending list:",list);

#deleting an element in list
del list[2];
print("List :",list);

4. Write a python program to perform functions in tuples


#Python Tuples


print("\t \t \t Python tuples");
tuple = ( 'abcd', 786 , 2.23, 'john', 70.2  ) tinytuple = (123, 'john') print("\ncomplete tuple :",tuple);

print("Prints first element of the tuple:", tuple[0]); print("Prints elements starting from 1nd to 3th:", tuple[1:4]); print("Prints elements starting from 3rd element:", tuple[2:]); print("Prints tuple two times:", tinytuple * 2          );
print ("concatenated tuple:",tuple + tinytuple );

5. Write a python program to perform functions in Dictionary.


#Python Dictionary
tinydict = {'name': 'john','code':6734, 'dept': 'sales'}
print ("Python Dictionary:" );
print ("complete dictionary",tinydict );
print ("Key :",tinydict.keys());          # Prints all the keys print ("values:",tinydict.values()); # Prints all the values


6. Write a python Program to select odd number from the lists


#!/usr/bin/python
a=[11,12,13,14,15,16,17,18,19,20,21,31,44,45,10]; print("List is:",a);
n=len(a); print("length:",n); i=0;
print("Odd number"); for i in range(len(a)): if(a[i]%2==1): print(a[i]);


7. Conditional statement in Python


>>> x = int(raw_input("Please enter an integer: "))
>>> if x < 0:
... x = 0
... print 'Negative changed to zero'
... elif x == 0:
... print 'Zero'
... elif x == 1:
... print 'Single'
... else:
... print 'More'


8. For Statement in Python


>>> # Measure some strings:
... a = ['cat', 'window', 'defenestrate']
>>> for x in a:
... print x, len(x)

cat 3
window 6

9. The Range() and Len() in Python


>>> a = ['Mary', 'had', 'a', 'little', 'lamb']
>>> for i in range(len(a)):
... print i, a[i]
...

10. Prime Number using Python.


>>> for n in range(2, 10):
... for x in range(2, n):
... if n % x == 0:
... print n, 'equals', x, '*', n/x
... break
... else:
... # loop fell through without finding a factor
... print n, 'is a prime number'

11. Simple Class Program in python


>>> class Complex:
... def    init   (self, realpart, imagpart):
... self.r = realpart
... self.i = imagpart
...
>>> x = Complex(3.0, -4.5)
>>> x.r, x.i
(3.0, -4.5)
12. Module Program in Python (Fibonacci Series)


A module is a file containing Python definitions and statements. The file name is the module name with the suffix .py appended. Within a
module, the modules name (as a string) is available as the value of the global variable    name   . For instance, use your favorite text editor to create a file called fibo.py in the current directory with the following contents:
Step  1:
Fibo.py
def fib(n):      # write Fibonacci series up to n a, b = 0, 1
while b < n:
print b,
a, b = b, a+b


Step 2:
>>> import fibo


Step 3:
>>> fibo.fib(1000)

















































RESULT:
Thus the program executed successfully

EX.NO:6                                          PERL PROGRAMMING

AIM:
Write a procedure to install Perl and also write a simple program.
PERL PROGRAMS
1. Sample PERL
#!usr/bin/perl        # the above line is shebang directive
$name=<STDIN>; chomp($name); print "$name\n";
2. Scalar variables in PERL
#!/usr/bin/perl
my $animal="Camel"; # this variable is lexically scoped ie local my $ans=42_243;  #this is similar to 42243
print "$animal\n";
print "$ans\n";
print "The square of &ans",$ans*$ans,"\n";
3. Array in PERL
#!usr/bin/perl
my @animal=("cow","Buffalo","Camel"); print "@animal\n"; # list all elements in array print "$#animal\n"; # list last element position print "$animal[0]\n"; #list 0th position element
print "$count";  # count no of elements in array
4. Hash in PERL
#!usr/bin/perl
%color=('apple'=>"red",'banana'=>"yellow",'orange'=>"orange");
print "$color{'apple'}\n";
5. To display all values in hash
#!usr/bin/perl
%color=('apple'=>"red",'banana'=>"yellow",'orange'=>"orange");
print "$color{'apple'}\n";
# to display all the values in hash
@keys=keys %color;
foreach $key (@keys)
{
print "$color{$key}\n";
}
6.If loop in perl
#!usr/bin/perl my $a=10;
$condition=1;
if($condition)
{
my $y=100; print "$a\n"; print "$y\n";
}
print "$a\n";
print "$y\n";
7. If not loop (unless)in perl
#!usr/bin/perl
$a=5;
unless($a>10) #is equal to if not
{print "a less than 10";}

8. While loop (until) in perl
#!usr/bin/perl
$a=0;
until($a>10) #is equal to while
{
print "$a\n";
$a++;
}
9. for each loop (upper limit is not fixed )in perl
#!usr/bin/perl
my @animals=("cow","buffalo","camel",123,100,243,300);
foreach $key(@animals)
{
print "$key\n";
}
10. String operation:
#!usr/bin/perl
$a="hello";
$b="world";
print $a.$b,"\n";
$str="-";
print $str x 80,"/n";
@a=(10..25);
print "@a\n";

11. Magic variable in perl
#!usr/bin/perl
%color=('apple'=>"red",'banana'=>"yellow",'orange'=>"orange");
$h=\%color;
print "$h\n";#print the reference address
@keys=keys %$h;
print "$h->{'apple'}\n"; # it print the the apple alone foreach (@keys)
{
print "$h->($_}\n"; # to display all key values we use $_ instead of keys
}
12 .Function
#!usr/bin/perl sub sayHello()
{print "Hello\n";
}
&sayHello();
13.Function with parameter
#!usr/bin/perl sub add(){
my ($a,$b)=@_; #the values will be stored in @_ array variable for dynamically
print $a+$b;
}
&add(10,15);
14.program to check greater among 3 number
#Greatest among 3 number print "Enter A value : ";
$a=<>;
print "Enter b value : ";
$b=<>;
print "Enter c value : ";
$c=<>;
if(($a > $b)&&($a > $c))
{

print "A is greater";
}
elsif(($b > $c)&&($b > $a))
{
print "B is greater";
}
else{
print "C is greater";
}




RESULT:
Thus Perl is installed and program is executed successfully.

EX.NO:7                                         NETWORK SIMULATOR

AIM:
Write a procedure to install Network Simulator.
PROCEDURE:
NETWORK SIMULATOR-2 is designed to run from on most UNIX based  operating   systems.Ns  is  a  discrete  event  simulator  targeted  at networking research. Ns provides substantial support for simulation of TCP, routing, and multicast protocols over wired and wireless (local and satellite) networks.
Download a copy of ns-allinone-2.34.tar.gz. Then from the command prompt there, execute the following:
tar -xzf ns-allinone-2.34.tar.gz cd ns-allinone-2.34
./install
(If this fails, try the Distribution Specific instructions)
After a long wait and a whole lot of text, you should see the installation finish up with text like the following:
Nam has been installed successfully.
Ns-allinone package has been installed successfully. Here are the installation places:
tcl8.4.11:        /home/pcraven/ns-allinone-2.29/{bin,include,lib} tk8.4.11:                                            /home/pcraven/ns-allinone-2.29/{bin,include,lib} otcl:          /home/pcraven/ns-allinone-2.29/otcl-1.11
tclcl:            /home/pcraven/ns-allinone-2.29/tclcl-1.17


ns:               /home/pcraven/ns-allinone-2.29/ns-2.29/ns nam:               /home/pcraven/ns-allinone-2.29/nam-1.11/nam xgraph: /home/pcraven/ns-allinone-2.29/xgraph-12.1
gt-itm:     /home/pcraven/ns-allinone-2.29/itm, edriver, sgb2alt, sgb2ns, sgb2comns, sgb2hierns
---------------------------------------------------------------------------------- Please put /home/myusername/ns-allinone-
2.29/bin:/home/myusername/ns-allinone-

2.29/tcl8.4.11/unix:/home/myusername/ns-allinone-2.29/tk8.4.11/unix into your PATH environment; so that you'll be able to run itm/tclsh/wish/xgraph.
IMPORTANT NOTICES:
(1) You MUST put /home/myusername/ns-allinone-2.29/otcl-1.11,
/home/myusername/ns-allinone-2.29/lib,
If it complains about X libraries, add path to your X libraries into LD_LIBRARY_PATH.
If you are using csh, you can set it like:
setenv LD_LIBRARY_PATH <paths> If you are using sh, you can set it like:
export LD_LIBRARY_PATH=<paths>
(2) You MUST put /home/myusername/ns-allinone-2.29/tcl8.4.11/library into your TCL_LIBRARY environmental
variable. Otherwise ns/nam will complain during startup.
(3) [OPTIONAL] To save disk space, you can now delete directories tcl8.4.11
and tk8.4.11. They are now installed under /home/myusername/ns- allinone-2.29/{bin,include,lib}


After these steps, you can now run the ns validation suite with cd ns-2.29; ./validate
For trouble shooting, please first read ns problems page http://www.isi.edu/nsnam/ns/ns-problems.html. Also search the ns mailing list archive for related posts.
At this  point,  you  should  follow  the  advice  here  and  update  your environment  variables.  You  should  also  add  ns-allinone-2.29/bin  to  you path. This has links to all the executables created by NS-2.  Since the Tcl scripts may call these executables (like nam or xgraph), it is a good idea to have them in the path.
You can test the installation by doing the following:
cd ns-2.29./validate
Note that this validation takes a really long time. If it starts out ok, you probably have a good installation.
At this point, you can see Getting Started with NS-2 .




RESULT:
Thus the Network Simulator has been installed successfully.








































































































now check the database as


mysql> select * from students;
+--------+---------------+
| rollno | sname           |
+--------+---------------+
|    100 | thamarai        |


|    200 | selvi            |
|   NULL | abcd              |
|      71 | thamaraiselvi |
+--------+---------------+
4 rows in set (0.00 sec)