cse exclusive

88
CSE Exclusive All stuffs for computer science And engineering students Home Posts RSS Comments RSS Edit Study of UNIX Operating System and c program for seccond semester record download 05:21 **************************** **************************** ***** Ex.No:1 Date: Reg No: Name:

Upload: hema2588

Post on 27-Nov-2014

120 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: CSE Exclusive

CSE Exclusive All stuffs for computer science And engineering students

Home

Posts RSS Comments RSS Edit

Study of UNIX Operating System and c program for seccond semester record download 05:21

*************************************************************

Ex.No:1                            Date:

Reg No:                                Name:

Study of UNIX Operating System

************************************************************* Aim

    To introduce the concept of UNIX Operating System

Page 2: CSE Exclusive

 Introduction

    An Operating System is an important part of a computer system. The computer system is built from the three general components.

1. The Hardware

2. The Operating System3. The Application Software's

 

 

 Applications

 

 

 

                                     Operating System

 

Page 3: CSE Exclusive

 

 

 

 

                                     Hardware

 

    

 An Operating System is a program that acts as an interface between the user and the computer. In fact, it is the one, which gets loaded into the computer memory first when the system is booted. It always 'lives' in memory, [keeps waiting] for commands and acts accordingly when it gets one. It is an intelligent servant and it controls and co-ordinates all the activities of the computer.

    Without an operating system, the most powerful computer in the world would be useless. The term UNIX is derived from UNICS means UNiplexed Information Computing Systems.

UNIX Operating System is a Multi-user and Multi-tasking Operating System. UNIX operating system is like a layer between the hardware and

Page 4: CSE Exclusive

the applications that run on the computer. It has functions that manage the hardware and functions that manage executing applications.

    The part of UNIX that manages the hardware and the executing processes is called the KERNEL.

 History of UNIX

    In late 1960's, Ken Thompson and Dennis Ritchie at AT&T Bell laboratories started writing an Operating System named as 'UNIX'. At first, UNIX was written in assembly language. Ken Thompson and Ritchie were not satisfied. They wanted a general Operating System that would run on any kind of hardware.

The whole UNIX OS was rewritten in 'C' language in 1973. Today, UNIX is a giant OS and has much powerful than most of its counterparts.

 The uniqueness or features of UNIX

The features that made UNIX a hit from the start are:

Multitasking capability

Multi-user capability Security Portability Communication Programming facility

Page 5: CSE Exclusive

 

Multitasking capability

    Multitasking is the capability of the operating system to perform various task simultaneously. I.e. A single user can run multiple tasks concurrently.

Multi-user capability

    Multi-user capability of UNIX allows several users to use the same computer to perform their tasks. Several terminals [Keyboards and Monitors] are connected to a single powerful computer [UNIX server] and each user can work with their terminals.

 

Security

    UNIX allows sharing of data; every user must have a single login name and password. So, accessing another user's data is impossible without his permission.

 

Portability

Page 6: CSE Exclusive

    UNIX is portable because it is written in a high level language. So, UNIX can be run on different computers.

 

Communication

UNIX supports the following communications.

Between the different terminals connected to the UNIX server.

Between the users of one computer to the users of another computer located on elsewhere.

 

Programming facility

    UNIX is highly programmable, the UNIX shell programming language has all the necessary ingredients like conditional and control structures (Loops) and variables, which establish it as a programming language in its own right.

 How UNIX is organized

The UNIX system is functionally organized at three levels:

Page 7: CSE Exclusive

The three levels of the UNIX system: kernel, shell, and tools and applications.

The kernel, which schedules tasks and manages storage;

The shell, which connects and interprets users' commands, calls programs from memory, and executes them; and

The tools and applications that offer additional functionality to the operating system

Kernel

    It is the core of the operating system. It controls all the tasks and carryout all the functions of an OS, such as memory management, file management, etc, and keeps track of programs that are executing. It also handles the information exchange between the terminals, such as tape drives and printers etc.

 

Shell

    It is command interpreter of the OS. The commands given from the user are moved to the shell. The shell, analyze and interprets these commands into machine understandable form. Hence shell acts as an interface between the user and the kernel.

 

Page 8: CSE Exclusive

o Tools and Applications

    It consists of Application Software, Compilers, Database Package, Internet tools, UNIX commands, etc.

 

 

        

    

    

 

 

 

 

 

Page 9: CSE Exclusive

 

                  Structure of UNIX

Advantages of UNIX

o UNIX allows only authorized users to modify files and directories.

o UNIX allows only system administrators to make changes in system configuration files.

o UNIX protects the system files from the VIRUS files and will not able to delete or modify the system files, because it will receive an "Access Denied" message.

o UNIX is very stable Operating System.o UNIX supports the Multi-User feature.o UNIX is a Multitasking Operating system.o UNIX can be loaded to any type of computer hardware.

File System

    A file is a collection of letters, numbers and special characters, it may be a program, or a database, or a simple letter etc.

    A file system is a group of files and relevant information regarding it. Everything in UNIX can be represented by a file such as Directories, Device Drives etc. Even your printer is a file. When you want to print something, you are just writing to a file (Printer).

Page 10: CSE Exclusive

    Although everything in UNIX is treated as a file. These are dividing into three categories.

    

 

 

 

 

 

 

 

 

 

 

Page 11: CSE Exclusive

 

o Ordinary files

    This is the traditional definition of a file. We can put anything into this type of file. This includes data, source programs, as well as any files created by the user. The most common type of ordinary file is the text file.

o Directory files

    A directory contains no external data, but keeps some details of the files and sub directories that it contains. The UNIX file system is organized with a number of such directories and sub directories and we can also create them as and when required.

o Device files

    The definition of this file has been broadened by UNIX to consider physical devices as files. This device files includes printers, tapes, floppy drives, hard disks and terminal etc.

    Device files are special files. Any output directed to device file will be reflected onto the respective physical device associated with file name. when the user issues a command to print a file, you are really directing the file's output to the file associated with the printer.

Page 12: CSE Exclusive

    All files in UNIX are related to one another. The file system of UNIX resembles a tree that grows from top to bottom as shown in the figure.

 

 

 

 

 

 

 

 

 

 

Page 13: CSE Exclusive

 

 

 

 

The file system begins with a directory called root (at the top). The root directory is denoted by a slash (\). Branching from root there are several directories called bin, lib, etc, tmp, dev.    Each of these directories contains several sub-directories and files.

 

*************************************************************

Ex.No:2                             Date:

Reg No:                            Name:

Basic Shell Commands

Page 14: CSE Exclusive

*************************************************************

Aim

    To study and execute the basic shell commands.

 Commands

 1. General purpose Commands

o [date]         – Used to display the current system date and time.

o [cal]          – Used to display the calendar.o [who]          – Used to display the login details.o [tty]          - Used to display the terminal name.o [uname]     - Used to display the machine name.o [echo]    - Used to display the message.o [banner]    - Used to display banner.o [clear]    - Used to clear the currently existing screen.o [exit]    - Used to exit from the currently existing telnet samba

screen.

 2. Directory related commands

Page 15: CSE Exclusive

o [pwd]    - Use to display the current working directory.

o [mkdir]    - Used to create a new directory o [cd]    - used to move from one directory to another.o [rmdir]    - Used to remove or delete the directory.

 

 3. File related commands

o [cat]    - Used to create a new file.

Used to display the contents in the file.

Used to concatenate multiple files into a single file.

o [cp]    - Used to copy the contents from one file to another file.o [mv]    - used to move the file from one place to another.o [rm]    - Used to remove or delete a file from directory.o [ls]    - Used to list the directory and files.o [cmp]    - Used to compare two files in the same directory.

 

 4. File permission related commands

Page 16: CSE Exclusive

o [chmod]    - used to set or remove file permissions.

 5. Command grouping commands

o [;]    - Used to separate multiple commands at the command line.

o [&&]    - Used to perform logical AND operation between two or more

o valid UNIX commands.o [||]    - Used to perform logical OR operation between two or

moreo valid UNIX commands

 6. Filters related commands

o [head]    - Used to display beginning of a file.

o [tail]    - Used to display end of the file.o [cut]    - Used to cut a file vertically.o [paste]    - Used to paste the contents.o [sort]    - Used to order a file.o [grep]    - Used to search for a pattern.

 

Page 17: CSE Exclusive

 7. I/O Redirection related commands

o [cmd>]    - Used to redirect standard output to a file.

    Used to redirect standard error.

o [cmd<]    - Used to redirect input from a file.

 8. Pipes

o [|]    - Used to redirect the output of one command into the input

of another command.

*************************************************************

Ex.No:3                            Date:

Page 18: CSE Exclusive

Reg No:                            Name:

AREA OF CIRCLE

*************************************************************

 CODING :

 

 echo "Enter the radius"

read r

a=`expr 22 \* $r \* $r / 7`

echo "The area of the circle of= $a "

 

 

 

 

Page 19: CSE Exclusive

 

 

 OUTPUT :

 

 Enter the radius

3

The area of the circle of= 28

 *************************************************************

Ex.No:4                            Date:

Reg No:                            Name:

BIGGEST AMONG THREE NUMBERS

*************************************************************

Page 20: CSE Exclusive

 

CODING :

 echo "Enter the 3 Numbers :"

read a b c

if [ $a -gt $b -a $a -gt $c ]

then

echo " $a is bigger than $b & $c "

elif [ $b -gt $c ]

then

echo " $b is bigger than $a & $c "

else

echo " $c is bigger than $a & $b "

fi

 OUTPUT:

Page 21: CSE Exclusive

 Enter the 3 Numbers :

1 2 3

3 is bigger than 1 & 2

 

 

*************************************************************

Ex.No:5                            Date:

Reg No:                            Name:

PRINT 'N' NATURAL NUMBERS

*************************************************************

 CODING:

 

Page 22: CSE Exclusive

echo " Enter limit"

read n

i=0

while [ $i -lt $n ]

do

i=`expr $i + 1`

echo "$i"

done

 OUTPUT:

 Enter limit

5

 1

2

3

Page 23: CSE Exclusive

4

5

        

*************************************************************

Ex.No:6                            Date:

Reg No:                            Name:

ARITHEMATIC OPERATIONS USING SWITCH CASE

*************************************************************

CODING:

i=0

while [ $i -eq 0 ]

do

Page 24: CSE Exclusive

echo " 1.Add , 2.Sub , 3.Mul , 4.Div "

read ch

echo " Enter 2 nos :"

read a b

case $ch in

1) s=`expr $a + $b` ;;

2) s=`expr $a - $b` ;;

3) s=`expr $a \* $b` ;;

4) s=`expr $a / $b` ;;

esac

echo " $s "

echo "Do you want to continue (0/1) :0 - Yes / 1 - No :"

read i

done

 

 

Page 25: CSE Exclusive

 OUTPUT :

1.Add , 2.Sub , 3.Mul , 4.Div

1

Enter 2 nos :

2 5

7

Do you want to continue (0/1) :0 - Yes / 1 - No :

0

1.Add , 2.Sub , 3.Mul , 4.Div

2

Enter 2 nos :

6 4

2

Do you want to continue (0/1) :0 - Yes / 1 - No :

0

1.Add , 2.Sub , 3.Mul , 4.Div

Page 26: CSE Exclusive

3

Enter 2 nos :

5 4

20

Do you want to continue (0/1) :0 - Yes / 1 - No :

1

 

 

*************************************************************

Ex.No:7                                    Date:

Reg No:                                    Name:

FACTORIAL OF GIVEN NUMBER

*************************************************************

Page 27: CSE Exclusive

 CODING :

 echo "Enter the number :"

read n

i=1

fact=1

while [ $i -le $n ]

do

fact=`expr $fact \* $i`

i=`expr $i + 1`

done

echo "The factorial of $n is $fact"

 

 

 

 

Page 28: CSE Exclusive

 

 

 

 

 OUTPUT:

 Enter the number :

3

The factorial of 3 is 6

sh fact

Enter the number :

0

The factorial of 0 is 1

sh fact

Enter the number :

1

Page 29: CSE Exclusive

The factorial of 1 is 1

 

*************************************************************

Ex.No:8                             Date:

Reg No:                             Name:

SQUARES AND CUBES

*************************************************************

 CODING:

echo "Enter the number:"

read n

i=1

echo "Number Square Cube "

Page 30: CSE Exclusive

while [ $i -le $n ]

do

s=`expr $i \* $i`

c=`expr $i \* $i \* $i`

echo "$i $s $c"

i=`expr $i + 1`

done

 

 

 

 

 

 

 

 

 OUTPUT:

Page 31: CSE Exclusive

 Enter the number:

5

Number Square Cube

1 1 1

2 4 8

3 9 27

4 16 64

5 25 125

 

*************************************************************

Ex.No:9                             Date:

Reg No:                             Name:

Page 32: CSE Exclusive

MENU DRIVEN COMMANDS

*************************************************************

 CODING:

 i=0

while [ $i -eq 0 ]

do

echo " MENU "

echo " 1. Display the current path"

echo " 2. Display the content of the file"

echo " 3. Delete a file "

echo " 4. List the files and directories "

echo " 5. List the current users"

echo " 6. Date "

echo " 7. Word Count"

Page 33: CSE Exclusive

echo " 8. Head Command"

echo " 9. Tail Command"

echo "10. Exit"

echo "Enter the choice:"

read ch

case $ch in

1) pwd;;

2) ls

echo "Enter the file name:"

read f

cat $f;;

3) ls

echo "Enter the file name:"

read f

rm $f;;

4) ls;;

5) who;;

Page 34: CSE Exclusive

6) date;;

7) ls

echo "Enter the file name:"

read f

wc $f;;

8) ls

echo "Enter the file name:"

read f

echo "Enter the No. of lines:"

read l

head -$l $f;;

9)ls

echo " Enter the file name:"

read f

echo "Enter the No.of lines :"

read l

Page 35: CSE Exclusive

tail -$l $f;;

10) exit;;

esac

echo "Do you want to continue 0/1 [ 0-Y & 1-N ]"

read i

done

 

 MENU

1. Display the current path

2. Display the content of the file

3. Delete a file

4. List the files and directories

5. List the current users

6. Date

7. Word Count

8. Head Command

Page 36: CSE Exclusive

9. Tail Command

10. Exit

Enter the choice:

1

/home/ITa42

Enter the choice:

2

aaa big2 circle fact menu-cmd pos-neg sq-cube tri

arith big3 even-odd matrixmul natural salary stud vircle

Enter the file name:

big2

echo "Enter 2 nos : "

read a b

if [ $a -gt $b ]

then

echo " $a is bigger the $b "

Page 37: CSE Exclusive

else

echo " $b is bigger the $a "

fi

Enter the choice:

3

aaa big2 circle fact menu-cmd pos-neg sq-cube tri

arith big3 even-odd matrixmul natural salary stud vircle

Enter the file name:

Vircle

Enter the choice:

4

aaa big2 circle fact menu-cmd pos-neg sq-cube tri

arith big3 even-odd matrixmul natural salary stud

Enter the choice:

5

ITa34 pts/2 Mar 26 09:15 (192.168.1.55)

ITa58 pts/6 Mar 26 09:52 (192.168.1.40)

Page 38: CSE Exclusive

ITa64 pts/5 Mar 26 09:53 (192.168.1.63)

ITa57 pts/12 Mar 26 10:01 (192.168.1.96)

ITa51 pts/1 Mar 26 10:01 (192.168.1.58)

ITa42 pts/3 Mar 26 10:02 (192.168.1.94)

ITa34 pts/0 Mar 26 10:03 (192.168.1.65)

ITa45 pts/11 Mar 26 10:04 (192.168.1.71)

exam011 pts/13 Mar 26 10:05 (192.168.1.83)

exam015 pts/15 Mar 26 10:06 (192.168.1.74)

Enter the choice:

6

Thu Mar 26 10:08:13 IST 2009

Enter the choice:

7

aaa big2 circle fact menu-cmd pos-neg sq-cube tri

arith big3 even-odd matrixmul natural salary stud

Enter the file name:

Page 39: CSE Exclusive

circle

6 23 100 circle

Enter the choice:

8

aaa big2 circle fact menu-cmd pos-neg sq-cube tri

arith big3 even-odd matrixmul natural salary stud

Enter the file name:

fact

Enter the No. of lines:

2

echo "Enter the number :"

read n

 Enter the choice:

9

aaa big2 circle fact menu-cmd pos-neg sq-cube tri

arith big3 even-odd matrixmul natural salary stud

Page 40: CSE Exclusive

Enter the file name:

fact

Enter the No.of lines :

5

fact=`expr $fact \* $i`

i=`expr $i + 1`

done

echo "The factorial of $n is $fact"

 Enter the choice:

10

 

Ex.No:10                              Date:

Reg No:                             Name:

ODD OR EVEN

Page 41: CSE Exclusive

*************************************************************

 

 CODING:

 echo "Enter the number "

read n

e=`expr $n % 2`

if [ $e -eq 0 ]

then

echo " The number $n is even "

else

echo " The number $n is odd "

fi

 OUTPUT:

Enter the number

Page 42: CSE Exclusive

2

The number 2 is even

sh even-odd

Enter the number

3

The number 3 is odd

 *************************************************************

Ex.No:11                            Date:

Reg No:                            Name:

POSITIVE OR NEGATIVE

*************************************************************

 

 CODING:        

Page 43: CSE Exclusive

 echo " Enter the number "

read n

if [ $n -gt 0 ]

then

echo "The number $n is positive "

elif [ $n -lt 0 ]

then

echo "The number $n is negative "

else

echo "0 is neither positive nor negative "

fi

 

 

 

 

Page 44: CSE Exclusive

 

 

 

 

 

 OUTPUT:

 Enter the number

3

The number 3 is positive

sh pos-neg

Enter the number

-3

The number -3 is negative

 

Page 45: CSE Exclusive

*************************************************************

Ex.No:12                            Date:

Reg No:                            Name:

SALARY COMPUTATION

*************************************************************

 

 CODING:

 echo "Enter the Basic Pay :"

read bp

da=`expr $bp \* 10 / 100`

hra=`expr $bp \* 20 / 100`

gs=`expr $bp + $da + $hra`

Page 46: CSE Exclusive

echo "-------------------------"

echo " SALARY CERTIFICATE "

echo "-------------------------"

echo " DA = $da"

echo " HRA = $hra"

echo " Gross Salary = $gs"

 

 

 

 

 

 

 

 OUTPUT:

 Enter the Basic Pay :

Page 47: CSE Exclusive

5000

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

     SALARY CERTIFICATE

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

     DA            = 500

     HRA          = 1000

     Gross Salary    = 6500

 

*************************************************************

Ex.No:    13                            Date:

Reg No:                            Name:

STUDENT DETAILS

*************************************************************

Page 48: CSE Exclusive

CODING:

 echo "Enter the number of students :"

read n

i=1

while [ $i -le $n ]

do

echo "Enter the Following :"

echo "Name :"

read name

echo "Reg.No :"

read reg

echo "Department:"

read dept

echo "Physics :"

read phy

echo "Chemistry :"

Page 49: CSE Exclusive

read chem

echo "Maths :"

read maths

echo "Computer :"

read comp

echo "English :"

read eng

tot=`expr $phy + $chem + $maths + $eng + $comp`

avg=`expr $tot / 5`

if [ $avg -gt 90 ]

then

gr=A

elif [ $avg -gt 75 -a $avg -lt 85 ]

then

gr=B

elif [ $avg -gt 65 -a $avg -lt 75 ]

Page 50: CSE Exclusive

then

gr=C

elif [ $avg -gt 49 -a $avg -lt 65 ]

then

gr=D

else

gr=fail

fi

i=`expr $i + 1`

echo " --------------------------------"

echo " STUDENT MARKLIST "

echo " --------------------------------"

echo " Name : $name "

echo " Reg.No : $reg "

echo " Physics : $phy "

echo " Chemistry : $chem "

echo " Maths : $maths "

Page 51: CSE Exclusive

echo " English : $eng "

echo " "

echo " Total : $tot "

echo " Average : $avg "

echo " Grade : $gr "

done

 OUTPUT:

 Enter the number of students :

1

Enter the Following :

Name :

jerome

Reg.No :

08106042

Page 52: CSE Exclusive

Department:

IT

Physics :

98

Chemistry :

99

Maths :

100

Computer :

100

English :

100

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

STUDENT MARKLIST

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

Name : jerome

Reg.No : 08106042

Page 53: CSE Exclusive

Physics : 98

Chemistry : 99

Maths : 100

English : 100

Total : 497

Average : 99

Grade : A

*************************************************************

Ex.No:14                                Date:

Reg No:                                Name:

FACTORIAL OF NUMBER USING RECURSIVE FUNCTION **********************************

Page 54: CSE Exclusive

***************************

CODING:

#include<stdio.h>

#include<stdlib.h>

int rec(int);

main()

{

int n;

printf("Enter Number");

scanf("%d",&n);

printf("The factorial is %d",rec(n));

}

int rec(int s)

{

int f;

if((s==1)||(s==0))

Page 55: CSE Exclusive

return(1);

else

f=s*rec(s-1);

return(f);

}

 

 OUTPUT:

 Enter Number 5

The factorial is 120

 

 

*************************************************************

Ex.No:15                            Date:

Page 56: CSE Exclusive

Reg No:                            Name:

STUDENT DETAILS USING POINTERS

*************************************************************

CODING:

#include<stdio.h>

#include<stdlib.h>

main()

{

struct student

{

char nm[25];

char rno[25];

char grade;

float avg;

int total,m1,m2,m3;

}

Page 57: CSE Exclusive

stud[50],*pt;

int i,j,n;

printf("Enter the number of students \n");

scanf("%d",&n);

for(i=0;i<n;i++)

{

printf("\n students[%d]information:\n",i+1);

printf("Enter name \n");

scanf("%s",stud[i].nm);

printf("\n Enter the register number");

scanf("%s",stud[i].rno);

printf("\n Enter 3 subject marks \n");

scanf("%d%d%d",&stud[i].m1,&stud[i].m2,&stud[i].m3);

stud[i].total=stud[i].m1+stud[i].m2+stud[i].m3;

stud[i].avg=stud[i].total/3;

}

Page 58: CSE Exclusive

pt=stud;

for(pt=stud;pt<stud+n;pt++)

{

if(pt->avg<30)

pt->grade='D';

else if((pt->avg<50)&&(pt->avg>=30))

pt->grade='C';

else if((pt->avg<70)&&(pt->avg>=50))

pt->grade='B';

else

pt->grade='A';

}

printf("\n");

printf("name\t\tregno\t\t total\t\t avg \t\tgrade \n");

{

for(pt=stud;pt<stud+n;pt++)

{

Page 59: CSE Exclusive

printf("%s\t%s",pt->nm,pt->rno);

printf("\t%d\t\t%f\t\t%c\n",pt->total,pt->avg,pt->grade);

}

}}

 

 OUTPUT:

Enter the number of students

2

students[1]information:

Enter name

BALA MURALI

 Enter the register number21708106019

 Enter 3 subject marks

Page 60: CSE Exclusive

95 65 68

 students[2]information:

Enter name

BALAJI

 Enter the register number21708106018

 Enter 3 subject marks

56 9 6

 name regno total avg grade

BALAMURALI 2170810619 228 76.000000 A

BALAJI 21708106018 71 23.000000 D

*************************************************************

Ex.No:16                                Date:

Page 61: CSE Exclusive

Reg No:                                 Name:

DYNAMIC MEMORY ALLOCATION – TO PRINT NUMBER IN REVERSE ORDER

*************************************************************

CODING:

#include<stdio.h>

main()

{

int n,i,*xp;

printf("\n Enter the limit");

scanf("%d",&n);

xp=(int*)calloc(n,2);

printf("\n Enter the %d values\n",n);

for(i=0;i<n;i++)

scanf("%d",(xp+i));

printf("\n The reversed list is \n");

for(i=n-1;i>=0;i--)

Page 62: CSE Exclusive

{

printf("%d\t",*(xp+i));

}

printf("\n");

}

 

 

 

 OUTPUT:

 Enter the limit5

 Enter the 5 values

1 2 3 4 5

 

Page 63: CSE Exclusive

The reversed list is

5 4 3 2 1

 

 

 

 

 

 

 

*************************************************************

Ex.No:17                            Date:

Reg No:                            Name:

DYNAMIC MEMORY ALLOCATION- PALINDROME

Page 64: CSE Exclusive

*************************************************************

 CODING:

 #include<stdio.h>

#include<string.h>

main()

{

char *st,*rst;

int i,j;

st=(char*)malloc(80);

rst=(char*)malloc(80);

printf("\n Enter the word\n");

scanf("%s",st);

i=strlen(st)-1;

j=0;

while(i>=0)

Page 65: CSE Exclusive

{

*(rst+j)=*(st+i);

j++;

i--;

}

*(rst+j)='\0';

if(strcmp(st,rst)==0)

printf("\n %s is a palindrome \n",st);

else

printf("\n %s is not a palindrome \n",st);

}

 

 

 

 

 

Page 66: CSE Exclusive

 OUTPUT:

 Enter the word

deepsaran

deepsaran is not a palindrome

 Enter the word

madam

madam is a palindrome

*************************************************************

Ex.No:18                                    Date:

Reg No:                                    Name:

Page 67: CSE Exclusive

FILE HANDLING –CREATING FILE AND COUNT VOWELS IN THAT FILE

*************************************************************

 

 CODING:

 #include<stdio.h>

#include<ctype.h>

main()

{

char ch;

int count=0;

FILE *fp;

fp=fopen("sample.txt","w");

printf("\n Type the text press enter key at the end \n")

while((ch=getchar())!='\n')

Page 68: CSE Exclusive

putc(ch,fp);

fclose(fp);

fp=fopen("sample.txt","r");

printf("\n The content of the text file is:\n");

while(!feof(fp))

{

ch=getc(fp);

printf("%c",ch);

switch(toupper(ch))

{

case 'A':

case 'E':

case 'I':

case 'O':

case 'U':count++;

break;

Page 69: CSE Exclusive

}}

printf("\n Number of Vowels present=%d\n",count);

fclose(fp);

}

 OUTPUT:

Type the text press enter key at the end

IAM A GOOD BOY

The content of the text file is:

IAM A GOOD BOY

Number of Vowels present=6

 

*************************************************************

Ex.No:19                            Date:

Page 70: CSE Exclusive

Reg No:                            Name:

CUBE OF A VALUE-CALL BY VALUE

*************************************************************

CODING:

 #include<stdio.h>

int interchange(int *a,int *b);

main()

{

int i,j;

printf("Enter the value of i,j:\n");

scanf("%d%d",&i,&j);

printf("i and j values before interchanging: %d\t%d\n",i,j);

interchange(&i,&j);

printf("i and j values after interchanging: %d\t%d\n",i,j);

printf("i and j values after interchanging in the main(): %d\t%d\n",i,j);

Page 71: CSE Exclusive

}

int interchange(int *a,int *b)

{

int t;

t=*a;

*a=*b;

*b=t;

return;

}

 OUTPUT:

 Enter the value of i,j:

5 6

i and j values before interchanging: 5 6

i and j values after interchanging: 6 5

Page 72: CSE Exclusive

i and j values after interchanging in the main(): 6 5

 

*************************************************************

Ex.No:20                            Date:

Reg No:                            Name:

INTERCHANGING TWO VALUES-CALL BY REFERENCE

*************************************************************

CODING:

 #include<stdio.h>

int cube (int x);

main()

{

int n;

Page 73: CSE Exclusive

printf("enter the no");

scanf("%d",&n);

printf("\ncube of %d is....%d\n", n, cube (n));

}

int cube(int x)

{

x=x*x*x;

return (x);

}

 

 

 

 

 

 OUTPUT:

Page 74: CSE Exclusive

 enter the no 8

 

cube of 8 is....512

 

 

 

 

 

 

 

 

 

Page 75: CSE Exclusive

 

 

 

 

 

 

 

 

LOYOLA INSTITUTE OF TECHNOLOGY

 

[Affiliated to Anna University]

 

Page 76: CSE Exclusive

Palanchur, Chennai – 602 103

 

 

 

 

 

 

 DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

GE2155 – COMPUTER PRACTICE LABORATORY-II

II- SEMESTER

 

Page 77: CSE Exclusive

MAY/JUNE-2010

 

 

 

CONTENTS

S. No Date Name of the Experiment Page

No Signature

1    Study Of Unix Operating System      

2    Basic Shell Commands      

3    Area of Circle      

4    Biggest Among Three Numbers      

5    Print 'N' Natural Numbers      

6    Arithmetic Operations Using Switch Case      

7    Odd or Even      

Page 78: CSE Exclusive

8    Positive or Negative      

9    Salary Computation      

10    Student Details      

11    Factorial Of Given Number      

12    Squares And Cubes      

13    Menu Driven Commands      

14    Factorial Of Number Using Recursive Function      

15    Student Details Using Pointers      

16   File Handling –Creating File And Count Vowels In That File

     

17   Dynamic Memory Allocation – To Print Number In Reverse Order

     

18    Dynamic Memory Allocation- Palindrome      

19    Cube Of A Value-Call By Value      

20    Interchanging Two Values-Call By Reference      

LOYOLA INSTITUTE OF TECHNOLOGY

Page 79: CSE Exclusive

[Affiliated to Anna University]

Palanchur, Chennai – 602 103

 

 

 

 

UNIVERSITY REGISTER NO:

 

CERTIFICATE

Certified to be bonafide record of work done by ________________ of II Semester B.E (COMPUTER SCIENCE & ENGINEERING) in the COMPUTER PRACTICE LABORATORY –GE2155 during the Academic Year 2009 – 2010.

 

Page 80: CSE Exclusive

 

HEAD OF THE DEPARTMENT                  STAFF-IN-CHARGE

Submitted for the University Practical Examination held on _______________

 

 

 

External Examiner                     Internal Examiner

POSTED BY SHANKAR

EMAIL THIS BLOGTHIS! SHARE TO TWITTER SHARE TO FACEBOOK SHARE TO

GOOGLE BUZZ

0 comments:

Post a Comment

Newer Post Older Post

Labelsebooks (4) EEE (1) Elective (3) Engineering ebooks (17) Extra (2) first year ebook (10) first year qpaper (10) first year syllabus (6) Lab (4) maths (3) MBA (1) MCA (1) Notes (2) OOAD (1) other (21) Paper Presentation (1) pass mark (2) Project (2) Question Bank (4) QUESTION PAPER (21) result (5) semester (30) Semester 1 (3) Semester 2 (3) Semester 3 (3) Semester 4 (4) Semester 5 (12)

Page 81: CSE Exclusive

semester 6 (3) Semester 7 (3) Semester 8 (25) SYLLABUS (146) timetable (14) university news (1)

About MeSHANKAR View my complete profile

Blog Archive ▼  2011 (125)

o ▼  May (69) DBMS RECORD Project Review Form Computer Organization & Architecture Notes - 4TH U... Do You Know What it stands for Digital Principles and System Design Question Bank... CS2308 SYSTEM SOFTWARE LAB MANUAL User Interface Design Question Bank C# Struct Examples How to create new project Study of UNIX Operating System and c program for s... Department of Information Technology2008 Regulatio... CREDIT CARD PROCESSING – OOAD Project STOCK MAINTANCE SYSTEM – ooad project PASSPORT AUTOMATION SYSTEM – OOAD experiment Cloud Computing - A Dreamed vision for Empowering ... CS2309 JAVA LAB CS2308 SYSTEM SOFTWARE LAB CS2307 NETWORK LAB CS2305 PROGRAMMING PARADIGMS CS2304 SYSTEM SOFTWARE CS2303 THEORY OF COMPUTATION

Page 82: CSE Exclusive

CS2302 COMPUTER NETWORKS MA2265 DISCRETE MATHEMATICS CS2301 SOFTWARE ENGINEERING ANNA UNIVERSITY COMPUTER SCIENCE AND

ENGINEERING ... SEMESTER 8 syllabus SEMESTER VIII – Elective subjects IT2064 SPEECH SIGNAL PROCESSING IT2033 BIO INFORMATICS GE2072 INDIAN CONSTITUTION AND SOCIETY GE 2023 FUNDAMENTALS OF NANOSCIENCE GE2021 PROFESSIONAL ETHICS IN ENGINEERING CS2064 AGENT BASED INTELLIGENT SYSTEMS CS 2063 GRID COMPUTING CS2057 KNOWLEDGE BASED DECISION SUPPORT

SYSTEM CS2062 QUANTUM COMPUTING CS2056 DISTRIBUTED SYSTEMS IT2403 SOFTWARE PROJECT MANAGEMENT CS2055 SOFTWARE QUALITY ASSURANCE IT2023 DIGITAL IMAGE PROCESSING CS2053 SOFT COMPUTING CS2061 ROBOTICS CS2060 HIGH SPEED NETWORKS IT2042 INFORMATION SECURITY CS2051 GRAPH THEORY GE2071 INTELLECTUAL PROPERTY RIGHTS (IPR) CS2045 WIRELESS NETWORKS CS2040 ADVANCED OPERATING SYSTEMS IT2401 SERVICE ORIENTED ARCHITECTURE IT2032 SOFTWARE TESTING IT2351 NETWORK PROGRAMMING AND

MANAGEMENT GE2022 TOTAL QUALITY MANAGEMENT IT2024 USER INTERFACE DESIGN IT2061 SYSTEMS MODELING AND SIMULATION

Page 83: CSE Exclusive

CS2035 NATURAL LANGUAGE PROCESSING IT2352 CRYPTOGRAPHY AND NETWORK SECURITY CS2041 C# AND .NET FRAMEWORK CS2034 TCP/IP DESIGN AND IMPLEMENTATION CS2033 REAL TIME SYSTEMS CS2032 DATA WAREHOUSING AND DATA MINING MG2453 RESOURCE MANAGEMENT TECHNIQUES CS2406 OPEN SOURCE LAB CS2405 COMPUTER GRAPHICS LABORATORY CS2403 DIGITAL SIGNAL PROCESSING CS2402 MOBILE AND PERVASIVE COMPUTING CS2401 COMPUTER GRAPHICS MG2452 ENGINEERING ECONOMICS AND FINANCIAL

ACCOUNT... ANNA UNIVERSITY COMPUTER SCIENCE AND

ENGINEERING ... ANNA UNIVERSITY COMPUTER SCIENCE AND

ENGINEERING ... o ►  March (11) o ►  February (7) o ►  January (38)

►  2010 (185) o ►  December (164) o ►  November (13) o ►  October (1) o ►  July (7)

 

Copyright © 2010 CSE Exclusive Design by dzignine Solaranlagen and Quotes Source