Computer Practice Lab Manual

58
PRIST UNIVERSITY (Estd. u/s 3 of UGC Act, 1956) _________________________________________________________________________________ 13150L16-Computer Practice Lab Manual Year /Semester PREPARED BY R.BHAVANI, D.VINOTHA, S.SATHISH KUMAR ASSISTANT PROFESSORS CSE DEPARTMENT October-2013 FACULTY OF ENGINEERING AND TECHNOLOGY

description

B.Tech First Year

Transcript of Computer Practice Lab Manual

Page 1: Computer Practice Lab Manual

PRIST UNIVERSITY

(Estd. u/s 3 of UGC Act, 1956)

_________________________________________________________________________________

13150L16-Computer

Practice Lab Manual

Year /Semester

PREPARED BY

R.BHAVANI, D.VINOTHA, S.SATHISH KUMAR

ASSISTANT PROFESSORS

CSE DEPARTMENT

October-2013

FACULTY OF ENGINEERING AND TECHNOLOGY

Page 2: Computer Practice Lab Manual

CONTENTS

NO EXPERIMENTS PAGE NO

MS WORD

1. a) Document creation.

b) Text manipulation with Scientific notations.

1

3

2. a) Table creation

b) Table formatting and conversion.

5

5

3. Mail merge and Letter preparation. 6

4. Drawing Flowchart. 6

SPREAD SHEET

5. Chart-Line ,Bar, pie 8

6. Formula –formula editor 9

7. Spread sheet inclusion of object, picture and graphics,

Protecting the document.

10

8. Sorting and Import/Export Features. 10

C Programming

9. Data types: a) Display Text and Numbers in the Screen

b) Addition of 2 Nos

34

35

10. Expression: a) Calculate the area of the circle. 36

b) Calculation of average of ‘N’ numbers.

c) Swapping of Two Numbers

37

38

11. Conditional: a) Find the Largest of three numbers

b) Check Whether a Number is Positive or

Negative or Zero.

c) Calculate Sum of Natural Numbers

d) Generations of Fibonacci series.

e) Simple Menu driven.

39

40

41

42

43

12. Arrays: a) To Display the Smallest and Largest of an

array

46

b) Sorting (Ascending&/Descending) an array. 47

c) Reverse an array 49

d) String Concatenation 51

13. Functions: a) Prime number.

b) Factorial using Recursive function.

52

54

14. Structure: Student mark sheet using Structure 55

Page 3: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

1 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

INTRODUCTION TO WORD PROCESSING

Word Processing is the process of creating, editing, and retrieving, storing and

printing text material in a required format. Ms-Word is a word processing program that

allows us to create documents such as Letters, Reports, Manuals and Newsletters etc.

Various features provided by ms-word are

Entering and Editing text

Viewing documents

Formatting text

Formatting documents

Printing

Creating Tables

Drawing Graphics

Mail Merge and Labeling

Starting Ms-Word:

Click on start Programs Microsoft Office Microsoft Word and click on

it.Microsoft word will be opened with a blank document.

Understanding the Screens: From the top view, the following are there in the window.

Title bar

Menu bar

Tool bar

Rulers

Editing area

Tool bar (Optional)

Status bar

1. a) DOCUMENT CREATION AND EDITING

Document is the paper containing the information or text or data. Document

creation is the process of creating the document any adding text with formatting, editing,

features etc.

Creation of a new document: 1. On the File menu, click New.

2. The new dialog box appears.

3. Click the general tab, choose blank document, and then click OK.

4. New Blank document appears.

Opening an existing document: 1. On the File menu, click Open.

2. The open dialog box appears.

3. Click the file you want to open and then click OK.

Page 4: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

2 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Saving a document:

1. On the File menu, click Save.

2. The Save dialog box appears.

3. Give the name of the file and then click OK.

4. The file will be saved with the corresponding name.

Text Selection:

Type of Selection Mouse Action

Any amount of text Drag over the text.

A word Double-click the word.

A line of text Move the pointer to the left of the line until it changes to a

right-pointing arrow, and then click.

A sentence Hold down CTRL, and then click anywhere in the sentence.

A paragraph

Move the pointer to the left of the paragraph until it changes

to a right-pointing arrow, and then double-click. Or triple-

click anywhere in the paragraph.

Multiple paragraphs

Move the pointer to the left of the paragraphs until it changes

to a right-pointing arrow, and then double-click and drag up

or down.

A large block of text Click at the start of the selection, scroll to the end of the

selection, and then hold down SHIFT and click.

An entire document Move the pointer to the left of any document text until it

changes to a right-pointing arrow, and then triple-click.

Keyboard Shortcut Cursor Movement

Shift + right One character to the right

Shift + left One character to the left

Ctrl + shift + right To the end of a word

Ctrl + shift + left To the beginning of a word

Shift + end To the end of a line

Shift + home To the beginning of a line

Shift + down One line down

Shift + up One line up

Ctrl + shift + down To the end of a paragraph

Ctrl + shift + up To the beginning of a paragraph

Shift + page down One screen down

Shift + page up One screen up

Page 5: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

3 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Ctrl + shift + home To the beginning of a document

Ctrl + shift + end To the end of a document

Alt + ctrl + shift + page down To the end of a window

1. b) TEXT MANIPULATION

Formatting texts is the process of changing the appearance of the document by

changing the font.

Formatting Texts: Select the text that you want to format and apply the following effects.

Format Menu

Bold Formatfontselect bold from font style

Italic Formatfontselect italic from font style.

Underline Formatfontselect underline style.

Center Formatparagraphselect center from text alignment.

Right , Left Formatparagraphselect right or left from text alignment.

Justify Formatparagraphselect justified from text alignment.

Adding Bullets and Numbering:

1) Add the texts for which the bullets are needed.

2) Go to format Bullets and Numbering Click the type of bullet.

3) The texts will appear with bullets.

Changing the Page Setup:

Page setup is the process of choosing the appropriate page, it‟s size, margins.

1. Click on file menu page setup.

2. Page setup dialog box appears.

3. Select the required Margins, Paper size, Paper Source and Layout.

4. Click OK.

Working with Fonts:

1. Choose the text.

2. Click on Format Font.

3. Font dialog box appears.

4. Select the required Font name, Font size, Font Style, Font color etc.,

5. If necessary, apply the effects (Strikethrough, Double strikethrough, Superscript,

Subscript etc.,)

Headers and Footers: Headers and footers allow the text, to appear in every page of the document above

or below the text area. Headers appear at the top of the page. Footers appear at the bottom

of the page.

1. On the View menu, click Header and Footer to open the header and footer area on

a page.

2. To create a header, enter text or graphics in the header area.

Page 6: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

4 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

3. To create footer, click Switch between Header and Footer on the Header and

Footer toolbar to move to the footer area, and then enter text or graphics.

4. If necessary, format text by using buttons on the Formatting toolbar.

5. When you finish, click Close on the Header and Footer toolbar.

Changing the Case: 1. Select the text you want to change.

2. On the Format menu, click Change Case.

3. Click the capitalization option you want.

Changing Line Spacing: 1. Select the text you want to change.

2. On the Formatting toolbar, click Line Spacing, and then do one of the

following:

To apply a new setting, click the arrow, and then select the number that you

want.

To apply the most recently used setting, click the button.

To set more precise measurements, click the arrow, click more, and then

select the options you want under Line Spacing.

Inserting symbols: Various symbols can also be added to the document, for better presentation of the

document.

1. Click where you want to insert the symbol.

2. On the Insert menu, click Symbol, and then click the Symbols tab.

3. In the Font box, click the font that you want.

4. Double-click the symbol that you want to insert.

5. Click Close.

SCIENTIFIC NOTATIONS The Scientific notations can be typed using superscript and subscript options.

Superscript places the text slightly above the line of normal printed text.

Subscript places the text slightly below line of normal printed text.

Eg: To type H20,

1. Type H2O.

2. Select 2 and go to font option from the format menu.

3. Choose subscript check box.

Eg: To type x2+y

2=6 equation.

4. Type x2+y2=6.

5. Select 2 and go to font option from the format menu.

6. Choose superscript check box.

Page 7: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

5 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

2. TABLE CREATION, FORMATTING AND CONVERSION

1. Click where you want to create a table.

2. On the Table menu, point to Insert, and then click Table.

3. Under Table size, select the number of columns and rows.

Converting Text to Table: When you convert text to a table, you separate text with a comma, tab, or other

separator character to indicate where a new column should begin. Use a paragraph mark

to begin a new row.

1. Indicate where you want to divide text into columns by inserting the separator

characters you want. For example, in a list with two words on a line, insert a

comma or a tab after the first word to create a two-column table.

2. Select the text you want to convert.

3. On the Table menu, point to Convert, and then click Text to Table.

4. Under Separate text at, click the option for the separator character you want.

Converting Table to Text: 1. Select the rows or table that you want to convert to paragraphs.

2. On the Table menu, point to Convert, and then click Table to Text.

3. Under Separate text with, click the option for the separator character you want to

use in place of the column boundaries. Rows are separated with paragraph marks.

Changing RowHeights and Column Widths: 1. Using the table table Properties dialog box the row heights can be varied.

2. Also the row and column heights and widths can be varied by using the mouse by

means of dragging it.

Inserting Rows and Columns:

1. Select the row in the table before which you want to insert a row.

2. Choose insertRows above (or) Rows Below.

3. Similarly columns can also be inserted.

4. Similarly, rows and columns can be deleted by moving to tabledeleterows

(or) columns.

Other operations using the table:

1. Splitting the cells: tablesplit cells.

2. Sorting the contents: table Sort.

3. Perform calculations: table Formula.

Page 8: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

6 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

3. MAIL MERGE AND LETTER PREPARATION Mail Merge facilitates the users who are having the need to send the same content

to multiple addresses. Mail merge creates a database of your contacts and merges the

main body of the letter and this database so that many personalized letters would be

generated.

Tools Letters and Mailings Mail Merge

Select the type of Document.

Select the Location of your letter.

Select the recipient‟s List.

Write your Letter.

Now view all the merged letters.

4. DRAWING FLOWCHARTS First, add the drawing toolbar by clicking View Toolbars Drawing.

Insert Picture Clipart.

Choose some picture.

Adjust its Color, Brightness, Shadow etc., using the Drawing toolbar.

Click Auto shapes Flowchart click and draw the required flowchart

symbol.

Page 9: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

7 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Spreadsheet:

A spreadsheet is a grid of rows and columns and is also called as a worksheet.

Spreadsheet programs are developed to automate tasks such as technical calculations,

inferential statistics, analyzing data etc.

Parts of spreadsheet:

Columns

Rows

Cells

Cell pointer.

Data in the spreadsheet can be divided into following:

Numbers

Text

Formulae

Operators:

i. Arithmetic operators

ii. Logical operators

These are used to compare two values and produce a logical result either True or

False, 0 or 1.

Operation Meaning

= Equal

> Greater than

< Lesser than

>= Greater than or equal to

<= Less than or equal to

<> Not equal to

iii. Text operators This operator joins two or more text values to produce a single combined

text values.

Operation Meaning

& Concatenation

Operation Meaning

+ Addition

- Subtraction

* Multiplication

/ Division

^ Exponentiation

Page 10: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

8 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Charts: A chart is a way to present a table of numbers visually. Displaying a data in a

well-conceived chart can make it more understandable, and often we can make our point

more quickly.

Elements of a Chart In Excel, chart can be either 2-D or 3-D. the elements of a 2-D chart are:

Y-Axis is called as the “series” or “Rank” axis. It shows the value of data points that are

plotted.

X-Axis is known as the “Category” axis, shows the categories of the data points that are

plotted.

Category names identify the individual data points and may be dated. The category

names are taken from the topmost row or the left-most column, depending on the

orientation of the sheet.

Legend is a set of tables that describe the data series.

Data marker is another tool used to differentiate one data series from another.

Tick marks are small lines used to divide the two axis and provide scaling.

Gridlines are displayed for both axis to help read the value of individual data points.

Gridlines are scaled according to the values on the axis and can be changed.

Data labels are displayed at times to show the value of data point.

Selected border identifies that a particular chart can be sized, moved or deleted and

contains nodes or handles for that purpose.

Besides the elements of a 2-D chart, 3-D charts have the following additional elements.

They are:

Z-Axis is called as the “value” axis and shows the value of the data points.

Wall is the background of the plotted area.

Corners can be rotated to give different views to the user.

Floor is the base upon which the series are plotted.

5. CHARTS – LINE, XY, BAR & PIE

1. Try with different types of graphs for the following data.

Over Runs per over

10 45 32

20 94 82

30 148 130

40 205 190

50 295 252

2. Create Bar, 3D, & Pie for the following

Year Product1 Product2 Product3 Product4

1989 1000 800 900 1000

1990 800 80 500 900

1991 1200 900 400 800

1992 400 200 300 100

1993 1800 400 400 1200

Page 11: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

9 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

3. Write a procedure to show only visible worksheet data in the chart.

4. Insert a picture in a chart

5. Select a different chart type for the existing chart.

6. FORMULA, FORMULA EDITOR

1. Calculate HRA, DA, TA, PF, GPF, LIC, GS, Deduction, Net salary for the given

data in a worksheet.

E.No Name Basic HRA DA TA PF GPF LIC GS DED NS

1 RANI 20,000

2 KANI 6000

3 VANI 5000

4 ANU 16000

5 DEEPA 15000

Where HRA is 18% of Basic, DA is 15% of Basic, TA is 12% of Basic, PF is 10% of

Basic, GPF is 5% of Basic, LIC is 7% of Basic.

HRA = Basic * 18/100

DA = Basic * 15/100

TA = Basic * 12/100

PF = Basic * 10/100

GPF = Basic * 5/100

LIC = Basic * 7/100

GS=Basic+HRA+TA+DA.

DED=PF+GPF+LIC,

NS=GS-DED

Sort all employees in alphabetical order.

2. Give the procedure of the following.

I ) To change the font type and size

II ) To insert rows & columns

III )To edit data in the worksheet

IV) Addition of headers and footers

3. Calculating the netpay of the employees following the conditions given below.

E.No Ename Basic DA HRA GPF GS Net Sal

100 Rani 4400

200 Deepa 5000

300 Vani 8900

DA: 56% of the basic pay if basic pay < 8000 else 44%

HRA: 12.5% of the basic pay

GPF: 10% of the basic pay

Page 12: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

10 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

IT: take the rates prevailing at present

Find who is getting Max. & Min. salary?

4. Create a suitable examination dBase & find the sum of the marks of each student &

the respective class secured by the students.

Rules:

Pass if marks in each subject >=35

Fail if marks in any subject < 35

Distinction if average >= 75

First class if avg. >= 60 but < 75

Second class if avg. >=50 but < 60

Third class if avg. >=35 but < 50

Display avg. marks of the class subject-wise & pass %

7. SPREADSHEET – INCLUSION OF OBJECTS, PICTURES & GRAPHICS

PROTECTING THE DOCUMENT AND SHEET 1. Insert object in the worksheet

2. Insert a picture in the worksheet

3. Insert a comment in the worksheet

4. Insert an Org. chart of a company in the worksheet

5. Write a procedure to Insert a function in the worksheet

6. Establish link between two or more worksheets

7. Protect a sheet in MS-Excel

8. Sorting & Import / Export features

1. Enter the following data into the worksheet using the Data Form command.

Employee No. Department Salary 1234 IT 15000

2345 CSE 14589

3456 ECE 13450

4567 IT 12356

5678 EEE 8654

6789 E&I 9795

7890 Mech 7543

8901 PHYSICS 7457

9012 CHEMISTRY 6756

0123 MATHEMATICS 7897

S. Name M1 M2 M3 TOTAL AVG. CLASS

RANI 80 78 66

VANI 86 93 74

DEEPA 56 80 56

KANI 79 75 87

MALA 69 66 45

Page 13: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

11 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Sort the data by” salary “ within the department using “ sort “ command.

Calculate total salary of each department using Auto filter.

2. Create Transport Reservation Sheet with the following description.

Passenger Name: Not exceed 20 characters with a display message. If exceeds,

use interactive display request “Please enter name”.

Gender: Male / Female options to select one. Use the interactive display

request “Enter gender please”

Seat Nos. :>1 &<=100 with display message if out of range. Use the interactive

display request “Enter seat number”

Class : First or Second or Third to select as required. Use the interactive

display request “Please select class”

Amount : If the class is First, then the amount is Rs.500, if the class is Second,

Rs.400 and if the class is Third, Rs.300.

3. Create a customs fill series.

4. Save the current workbook in another program.

Page 14: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

12 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

1. INTRODUCTION TO ‘C’ LANGUAGE „C‟ is a structured programming language. It is originally developed at the

AT &T‟s Bell laboratories at USA in 1972 by Dennis Ritchie.

Advantages of ‘C’: Robust language

Rich set of built in functions and operators

Efficient and fast due to variety of datatypes,keywords,etc

Highly portable

2. STRUCTURE OF A ‘C’ PROGRAM

[Header files inclusions]

[Macro / constant definitions]

[Global variable declarations]

/* Comments can be included anywhere inside the program*/

main( )

{

Local variable declarations;

Set of statements;

}

[User defined functions]

{

Set of statements;

[Return;]

}

NOTE: The statements inside brackets[] are optional.

3. FORMATTED INPUT AND OUTPUT FUNCTIONS Input statement syntax :

scanf(“control string”,arg1,arg2,….argn);

Output statement syntax :

printf(“control string”,arg1,arg2,….argn);

4. CONDITIONAL STATEMENTS Conditional statements are the statements which are used to change the execution order

of statements based on condition or to repeat a set of statements until certain conditions

are met.

1. IF STATEMENT:

if(condition)

{

True statements;

}

2. IF-ELSE STATEMENT:

if(condition)

Page 15: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

13 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

True statements;

else

false statements;

3. NESTED IF…..ELSE STATEMENT:

if(condition 1)

{

if(condition 2)

True statement 2;

else

false statement 2;

}

else

false statement 1;

4. SWITCH STATEMENT:

switch(expression)

{

case: constant 1

block 1;

break;

case :constant 2

block 2;

break;

--

--

default:

default block;

break;

}

5. DECISION MAKING AND LOOPING In „C‟ program there is a need to repeat a set of instructions in specified number of times

or until a particular condition is being satisfied .This repetitive operations are done

through a loop control structure.

1. THE WHILE LOOP:

while (condition)

{

body of the loop;

}

2. THE DO…WHILE LOOP:

do

{

body of the loop;

…..

}while(condition);

Page 16: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

14 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

3. THE FOR LOOP:

for(initialize counter; test condition; increment/decrement counter)

{

body of the loop;

}

(ie) : Initialize counter-initialize counter variable.

Test condition-test the condition.

Increment/decrement counter-increment or decrement counter Variable.

6. FUNCTION Elements of User-Defined Functions a)Function definition

b)Function call

c)Function declaration

FUNCTION DECLARATION:

Return type function name (parameters list);

Eg:int add(int x,int y,int z);

Parameters(Arguments)

There are two types of parameters

i)Actual parameter: These are the parameters transferred from the calling function(main

program) to the called program(function)

ii)Formal parameter:These are the parameters transferred into the calling function(main

program)from the called program(function)

Eg:

main( )

{

……….

fun1(a,b);

……..

}

fun1(x,y)

{

……

……

}

where, a,b are the actual parameters

x,y are the formal parameters

Page 17: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

15 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

The return statement: The return statement may o may not send back any values to the main program(calling

program).

Syntax :

return;

Or

return(exp);

where, return-does not return any values

return(exp)-returns the value to main program.

Note: By default all functions return int datatype

Function Prototypes (Parameter Passing): i) Function with no arguments and no return value

Syntax:

main( )

{

……. fun1( )

……. {

………

.……… ……..

}

fun1( );

……

}

ii)Function with arguments and no return value

Syntax:

main( )

{

……. fun1( x,y)

……. {

………

.……… ……..

}

fun1(a,b );

……

}

iii) Function with arguments and with return value

Syntax:

main( )

{

……. datatype fun1( x,y)

……. {

………

Page 18: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

16 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

.……… return(z);

}

c=fun1(a,b );

……

}

iv) Function with no arguments and with return value

Syntax:

main( )

{

……. Datatype fun1( )

……. {

………

.……… return(z);

}

c= fun1( );

……

}

NOTE: The continuous line indicates data transfer and dotted line indicates transfer of

control.

7. RECURSION Process of calling the same function itself again and again until some condition is

satisfied.

Syntax:

function1( )

{

function1( );

}

8. ARRAYS An array is a collection of similar datatypes,that are stored under a common name.

ARRAY DECLARATION:

Syntax: datatype array_variable[size of the array];

where, Size -- Specifies the maximum number of elements are enclosed within

subscript..

ARRAY INITIALIZATION:

Syntax:datatype array name[size]={list of values};

where, list of values must be separated by commas.

TWO-DIMENSIONAL ARRAY:

Syntax:datatype arrayname [rowsize][column size];

FOR INITIALISING A TWO -DIMENSIONAL ARRAY:

Page 19: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

17 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Syntax: datatype arrayname[rowsize][columnsize]={list of values};

9. POINTERS It is a variable that contains the address of some other variable.

Syntax:datatyp

e *ptrvar;

Eg:

int *a,b;

b=5;

a=&b;

Now the pointer variable a contains the address of b.

10. STRUCTURE A Structure is a collection of data items or variables of different types that is

referenced under the same name.

Syntax:

struct structure_name

{

datatype member1;

datatype member2;

.

.

datatype member n;

};

Eg:

struct Student

{

Char name[20];

int rollno;

float mark;

};

1. a) Document creation.

b) Text manipulation with Scientific notations.

2. a) Table creation

b) Table formatting and conversion.

3. Mail merge and Letter preparation.

4. Drawing Flowchart.

Page 20: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

18 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Page 21: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

19 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:1a DOCUMENT CREATION

Microsoft Word Basic Features

When you type information into Microsoft Word, each time you press the Enter key Word creates a new paragraph. You can format paragraphs.

Type, Backspace, and Delete Insert and Overtype Bold, Italicize, and Underline Save the file.

PRIST UNIVERSITY

Page 22: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

20 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:1b TEXT MANIPULATION

Vallam ,Thanjavur

Facility :

Quality and well experienced Professors and Lecturers

Dedicated and Qualified laboratory technicians and staff

Committed to impart quality technical education

Facilities to the learning process by being a catalysts

Email: [email protected]

STUDENT AMENITIES: Student Canteen, Library with WIFI Internet facility

Page 23: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

21 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:2a TABLE CREATION

Click where you want to create a table.

On the Table menu, point to Insert, and then click Table.

Under Table size, select the number of columns and rows.

I Yr ‘A’ SEC STUDENT MARK LIST

ROLL

NO NAME ENGLISH MATHS PHYSICS CHEMISTRY EG FOC TOTAL

1001 Anitha 60 55 50 53 52 80 350

1002 Bhuvana 70 85 65 76 45 85 426

1003 Caroline 50 70 80 82 76 90 448

1004 Deepa 55 60 72 73 56 70 386

1005 Elavarasi 65 70 67 56 50 75 383

Page 24: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

22 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:2b TABLE FORMATTING Changing RowHeights and Column Widths:

Using the table table Properties dialog box the row heights can be varied.

Also the row and column heights and widths can be varied by using the mouse by

means of dragging it.

Inserting Rows and Columns:

Select the row in the table before which you want to insert a row.

Choose insertRows above (or) Rows Below.

Similarly columns can also be inserted.

Similarly, rows and columns can be deleted by moving to tabledeleterows

(or) columns.

Other operations using the table:

Splitting the cells: tablesplit cells.

Sorting the contents: table Sort.

Perform calculations: table Formula.

ROLL

NO NAME ENGLISH MATHS PHYSICS CHEMISTRY EG FOC TOTAL

1001 ANITHA 60 55 50 53 52 80 350

1002 BHUVANA 70 85 65 76 45 85 426

1003 CAROLINE 50 70 80 82 76 90 448

1004 DEEPA 55 60 72 73 56 70 386

1005 ELAVARASI 65 70 67 56 50 75 383

Page 25: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

23 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:3 MAIL MERGE AND LETTER PREPARATION

From:

The Administrator,

PRIST University,

Vallam ,

Thanjavur .

To,

Dear Student,

Last due date for pay the hostel fees is 22-07-2011. If you pay after

the due date, you should pay with fine Rs.1000/-

By,

The

Administrator

Page 26: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

24 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

RECIPIENTS LIST

Page 27: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

25 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

From:

The Administrator,

PRIST University,

Vallam ,

Thanjavur .

To,

«First_Name»,

«Last_Name»,

«Address_Line_1»,

«City» - «PIN_Code».

Dear Student,

Last due date for pay the hostel fees Rs.10000/- is 22-11-2011. If you

pay after the due date, you should pay with fine Rs.1000/-

By,

The

Administrator

Page 28: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

26 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

From:

The Administrator,

PRIST University,

Vallam ,

Thanjavur .

To,

A.Jayachandran,

K.Anbalagan,

44, Car Street,

Illuppur - 622102.

Dear Student,

Last due date for pay the hostel fees Rs.10000/- is 22-11-2011. If you

pay after the due date, you should pay with fine Rs.1000/-

By,

The

Administrator

Page 29: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

27 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:4 FLOW CHART

Start

Read S1, S2

for(i = 1; i<2; i++)

if

S1[i] = s2[i]

Print “Both

Strings are

Equal”

Print “Both

Strings are not

Equal”

Stop

Page 30: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

28 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Page 31: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

29 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:5 CHARTS

RollNo Name English Maths Physics Chemistry EG FOC Total Average

1001 A 60 55 50 53 52 80 350 58.33333

1002 B 70 85 65 76 50 85 431 71.83333

1003 C 50 70 80 82 76 90 448 74.66667

1004 D 55 60 72 73 56 70 386 64.33333

1005 E 65 70 67 56 50 75 383 63.83333

Page 32: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

30 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:6 FORMULA EDITOR

PAY BILL

S.NO NAME BASIC PAY DA HRA GPF GROSSPAY NETPAY

1 A 8900 700 850 765 10450 9685

2 B 7850 600 750 600 9200 8600

3 C 9750 750 900 800 11400 10600

4 D 6500 550 800 600 7850 7250

5 E 4500 325 565 420 5390 4970

MINIMUM 4970

MAXIMUM 10600

Page 33: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

31 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:7 SPREAD SHEET-INSERTING PICTURES

Page 34: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

32 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:8 SORTING AND IMPORT/EXPORT FEATURES

Page 35: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

33 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Page 36: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

34 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

DATA TYPES:

EX.NO:1 DISPLAY TEXT AND NUMBERS IN THE SCREEN

Aim :

To output some Text and Numbers on the Screen

Algorithm : Step 1 : Start the program

Step 2 : Printf function prints the “C programming” word 2 times .

Step 3 : Read an integer number x

Step 4 : Read a float number y

Step 5 : Print the numbers x and y

Step 6 : Stop the program

Program:

#include <stdio.h>

#include <conio.h>

void main()

{

int x; float y;

clrscr();

printf("See the curser where it is... ");

printf(" \n C Programming");

printf(" \t C Programming");

printf(" \n C Programming");

printf("----------------------------------------------");

printf("Enter an integer number: ");

scanf("%d",&x);

printf("Enter a float number: ");

scanf("%f",&y);

printf(" \n Entered integer number is %d ", x);

printf(" \n Entered float number is %f ", y);

getch();

}

Output:

See the curser where it is...

C Programming C Programming

C Programming

Entered integer number is 45

Entered float number is 45.67

Result :

Hence the program was implemented successfully using C.

Page 37: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

35 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:2 ADDITION OF TWO NUMBERS

Aim :

To find the sum of two number.

Algorithm :

Step 1 : Start the program

Step 2 : Declare the variable num1, num2 and sum

Step 3 : Read the 2 variables num1 and num2

Step 4 : add num1 and num2 and store it in sum

Step 5 : Display the sum

Step 6 : Stop the program

Program:

#include <stdio.h>

#include<conio.h>

void main( )

{

float num1, num2, sum;

clrscr();

printf("Enter two numbers: ");

scanf("%f %f",&num1,&num2);

sum=num1+num2; /* Performs addition and stores it */

printf(" \n Sum of %f and %f is %f ",num1, num2, sum);

getch();

}

Output:

Enter two numbers:

2.4

1.1

Sum of 2.4 and 1.1 is : 3.50000

Result: Hence the program to find the sum of two numbers was implemented.

Page 38: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

36 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:3 CALCULATE THE AREA OF THE CIRCLE

Aim :

To create a “C” program to calculate the area of the circle.

Algorithm :

1. Start the program

2. Define the value of PI = 3.14

3. Read the value of the radius

4. Calculate the area of the circle using the formula a= PI * r*r

5. Display the area

6. Stop the program

Program :

#include <stdio.h>

#include<conio.h>

#define PI 3.141

void main()

{

float r, a;

clrscr();

printf(" Enter the Value for Radius: ");

scanf("%f", &r);

a = PI * r * r;

printf(" \n %f\n", a);

getch();

}

Output:

Enter the Value for Radius: 2

12.564

Result :

Thus the “C” program to calculate the area of the circle was implemented.

Page 39: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

37 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:4 CALCULATION OF AVERAGE OF ‘n’ NUMBERS

Aim :

To write a “C” program to calculate the average of „n‟ numbers

Algorithm :

1. Start the program

2. Initialize sum as zero

3. Read the value of n

4. For count = 1 to n

a. Read the value of x

b. Add x to sum

5. Compute the average = sum/n

6. Print the average

7. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

int n, count;

float sum = 0, x, avg;

printf("\n Enter How Many Numbers : ");

scanf("%d", &n);

for(count = 1; count <= n; count++)

{

printf("x = ");

scanf("%f", &x);

sum += x;

}

avg = sum / n;

printf("\nThe Average of Numbers is : %0.2f", avg);

getch();

}

Output:

Enter How Many Numbers: 3

2

3

4

The Average of Numbers is: 3.00

Result :

Thus the “C” program to calculate the average of „n‟ numbers was executed.

Page 40: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

38 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:5 SWAPPING OF TWO NUMBERS

Aim :

To create a “C” program to swap two numbers.

Algorithm :

1. Start the program

2. Read the value of a

3. Read the value of b

4. Print the values of a and b before swapping

5. Store the value of a in variable temp

6. Store the value of b in variable a

7. Store the value of temp in variable b

8. Print the values of a and b after swapping

9. Stop the program

Program :

#include <stdio.h>

#include<conio.h>

void main()

{

float a, b, temp;

clrscr();

printf("Enter value of a: ");

scanf("%f",&a);

printf("\nEnter value of b: ");

scanf("%f",&b);

printf("\nBefore swapping, value of a = %.2f\n", a);

printf("Before swapping, value of b = %.2f\n", b);

temp = a;

a = b;

b = temp;

printf("\nAfter swapping, value of a = %.2f\n", a);

printf("After swapping, value of b = %.2f", b);

getch();

}

Output:

Enter value of a: 1.20

Enter value of b: 2.45

Before swapping, value of a = 1.20

Before swapping, value of b = 2.45

After swapping, value of a = 2.45

After swapping, value of b = 1.2

Result :

Thus the “C” program is created for swapping two numbers.

Page 41: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

39 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:6 LARGEST OF THREE NUMBERS

Aim : To write a “C” program to find the largest of three numbers.

Algorithm

1. Start the program

2. Enter three numbers a, b, and c

3. Check if(a>=b && a>=c) then print the value of „a‟ is largest.

4. Else again check if (b>=a && b>=c) then print the value of „b‟ is largest.

5. If both the rules in line numbers 3 and 4 are false print the value of „c‟ is

largest.

6. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

float a, b, c;

clrscr();

printf("Enter three numbers: ");

scanf("%f %f %f",&a,&b,&c);

if(a>=b && a>=c)

printf("\nLargest number = %.2f", a);

if(b>=a && b>=c)

printf("\nLargest number = %.2f", b);

if(c>=a && c>=b)

printf("\nLargest number = %.2f", c);

getch();

}

Output:

Enter three numbers:

78.04

31.76

09.54

Largest number = 78.04

Result :

Thus the „c‟ program was implemented to find the largest of three numbers.

Page 42: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

40 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO: 7 CHECK WHETHER A NUMBER IS POSITIVE OR

NEGATIVE OR ZERO.

Aim:

To write a program to check whether a given number is positive or negative or zero.

Algorithm:

1. Start the program

2. Read a number „num‟

3. Check if the value of num is less than or equal to zero

4. If true then check if the value of num is equal to zero

a) If true print the message “You entered zero”

b) If false print the given number is negative number.

5. If false then print the given number is positive number.

6. Stop the program.

Program:

#include <stdio.h>

#include<conio.h>

void main()

{

float num;

clrscr();

printf("Enter a number: ");

scanf("%f",&num);

if (num<=0)

{ if (num==0)

printf("You entered zero.");

else

printf("%.2f is negative.",num);

}

else

printf("%.2f is positive.",num);

getch();

}

Output 1 Enter a number: 12.3

12.30 is positive.

Output 2 Enter a number: -12.3

-12.30 is negative.

Output 3 Enter a number: 0

You entered zero.

Result :

Thus the „C‟ program was successfully implemented.

Page 43: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

41 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:8 CALCULATE SUM OF NATURAL NUMBERS

Aim :

To write a “C” program to calculate the sum of natural numbers

Algorithm :

1. Start the program

2. Read an integer „n‟

3. Initialize the value of count as 1 and sum as zero.

4. Until the value of count<= n repeat the steps from 5 to 7

5. Calculate sum = sum+ count

6. Increment the value of count as 1

7. Go to step 4

8. Print the value of sum.

9. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

int n, count, sum=0;

clrscr();

printf("Enter an integer: ");

scanf("%d",&n);

count=1;

while(count<=n)

{

sum+=count;

++count;

}

printf("\nSum = %d",sum);

getch();

}

Output :

Enter an integer: 10

Sum = 55

Result :

Thus the „C‟ program to calculate the sum of natural numbers was implemented.

Page 44: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

42 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:9 GENERATION OF FIBONACCI SERIES

Aim :

To write a “C” program to generate the Fibonacci series

Algorithm :

1. Start the program

2. Declare the variable i , k as integer

3. Assign f0 = -1 , f1 = 1 , f2 = 0

4. Read the value for “k”

5. Assign i = 1

6. Repeat the step 7 to 10 until i <= k

7. Compute f2 = f0 + f1

8. Print the value of f2

9. Assign f0 = f1 and f1 = f2

10. Increment the value of i by 1

11. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

int i,k,f0=-1,f1=1,f2=0;

clrscr();

printf("enter ther number of elements:");

scanf("%d",&k);

printf("FIBONACCI SERIES\n");

for(i=1;i<=k;i++)

{

f2=f0+f1;

printf("%d\t",f2);

f0=f1;

f1=f2;

}

getch();

}

Output :

Enter the number of elements:8

FIBONACCI SERIES

0 1 1 2 3 5 8 13

Result :

Thus the “C” program to generate fibonacci series was implemented.

Page 45: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

43 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX. NO 10: SIMPLE MENU DRIVEN CALCULATOR

Aim:

To write a simple menu driven calculator program using switch statement.

Algorithm:

Step 1 : Start the program

Step 2 : Display the menu

Step 3 : Read the two variable a and b

Step 4 : Enter the option code

Step 5 : Evaluate option code with case constant

Step 5.1 Case 1

C = a + b

Print c

Go to step 7

Step 5.2 Case 2

C = a - b

Print c

Go to step 7

Step 5.3 Case 3

C = a * b

Print c

Go to step 7

Step 5.4 Case 4

C = a / b

Print c

Go to step 7

Step 6 : If the case option is invalid code then print “Invalid operation code “

Step 7 : Stop the program

Page 46: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

44 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Program:

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,n;

clrscr();

printf(“MENU”);

printf(“1.Addition \n”);

printf(“2.Subtraction \n”);

printf(“3.Multiplication \n”);

printf(“4.Division\n”);

printf(“5.Exit\n”);

printf(“Enter Your Choice\n”);

scanf(“%d”,&n);

if(n<=4&&n>0)

{

printf(“Enter the two numbers”);

scanf(“%d%d”,&a,&b);

}

switch (n)

{

case 1:

c=a+b;

printf(“Addition:%d\n”,c);

break;

case 2:

c=a-b;

printf(“Subtraction:%d\n”,c);

break;

case 3:

c=a*b;

printf(“Multiplication:%d\n”,c);

break;

case 4:

c=a/b;

printf(“Division:%d\n”,c);

break;

case 5:

exit(0);

break;

default:

printf("Invalid Selection");

}getch();

}

Page 47: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

45 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Output :

MENU

1.Addition

2.Subtraction

3.Multiplication

4.Division

5.Exit

Enter your choice : 1

Enter the two numbers : 10 5

Addition : 10

(Again run 3 times for other operations)

Subtraction: 5

Multiplication: 50

Division: 2

Result :

Thus the simple menu driver calculator program was created successfully.

Page 48: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

46 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX. NO 11: TO DISPLAY THE SMALLEST AND LARGEST ELEMENTOF AN

ARRAY

Aim :

To create a “C” program to find the largest and smallest number using array

Algorithm :

1. Start the program

2. Enter the size of the array

3. Enter the elements of the array

4. Print the array elements

5. Initialize the largest and smallest is equal to the first element of the array

6. Stop the loop up to the array size

7. Check the next element greater than the large, if it is true then assign the next

element to the large

8. Check the next element smaller than the large, if it is true then assign the next

element to the small

9. Print the value of large and small after the execution of the loop

10. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

int i,n,a[10],large,small;

clrscr();

printf("enter the size of the list\t\n");

scanf("%d",&n);

printf("enter the elements\n\n");

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

scanf("%d",&a[i]);

small=a[0];

large=a[0];

for(i=1;i<n;i++) {

if(large<a[i])

large=a[i];

if(small>a[i])

small=a[i]; }

printf("largest element in the list is:%d\n\n",large);

printf("smallest element in the list is:%d\n\n",small);

getch();}

Output :

Enter the size of the list 5

Enter the elements: 52 65 84 92 37

Largest element in the list is:92

Smallest element in the list is:37

Result :Thus the “C” program to find the largest and smallest number using array was

implemented.

Page 49: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

47 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:12 SORTINGAN ARRAY (ASCENDING & DESCENDING)

Aim :

To write a “C” program to sort the given array in ascending and descending .

Algorithm :

1. Start the program

2. Enter the size of the array

3. Enter the elements of the array

4. Set a loop up to the array size minus one

5. Set a inner loop up to the size of the array

6. Check whether the next array element is greater than or not

7. If it is greater ,then exchange their position

8. If not then go to the loop

9. After the execution of the inner loop the outer loop is executed

10. Print the ascending order of the given array

11. Print the descending order of the given array

12. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

int i,j,n,a[10],temp;

clrscr();

printf("Enter the size of the list \t\n");

scanf("%d",&n);

scanf("Enter the elements one by one\n\n");

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

{

scanf("%d",&a[i]);

}

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

for(j=i+1;j<n;j++)

{

if(a[i]>a[j])

Page 50: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

48 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

{

temp=a[i];

a[i]=a[j];

a[j]=temp;

}

}

printf("Ascending order\n\n");

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

{

printf("%d\n",a[i]);

}

printf("Descending order \n\n");

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

{

printf("%d\n",a[i]);

}

getch();

}

Output :

Enter the size of the list 3

Enter the elements one by one

15

84

35

Ascending order

15

35

84

Descending order

84

35

15

Result :

Thus the “C” program to sort the given array in ascending and descending order

was implemented.

Page 51: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

49 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:13: REVERSE AN ARRAY

Aim :

To write a “C” program to reverse the elements given in an array

Algorithm :

1. Start the program

2. Read the value of “num”

3. Assign i=0

4. Repeat the step 5 and 6 until i <= num

5. Read x[i]

6. Compute i=i+1

7. Assign i=num (last index)

8. Repeat the step 9 and 10 until i >= 0

9. Read x[i]

10. Compute i=i+1

11. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

int x[10],i,num;

clrscr();

printf("Enter the number of elements :\n");

scanf("%d",&num);

printf("Enter the elements of array one by one:\n");

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

{

scanf("%d",&x[i]);

}

printf("Reverse array is \n");

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

{

printf("%d\t\n",x[i]);

}

getch();

Page 52: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

50 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

}

Output :

Enter the number of elements :

5

Enter the elements of array one by one:

10

11

12

13

14

Reverse array is

14

13

12

11

10

Result :

Thus the “C” program to perform the reverse operation was implemented.

Page 53: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

51 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:14 STRING CONCATENATION

Aim:

To write a C program to concatenate two strings using string function.

Algorithm:

1. Start the program

2. Read the first string s1

3. Read the second string s2

4. Combine the two strings s1 and s2 using strcat() function

5. Display the concatenated string.

6. Stop the program.

Program :

#include<stdio.h>

#include<conio.h>

#include<sting.h>

void main()

{

char s1[20],s2[20];

clrscr();

printf("Enter the first string\n");

gets(s1);

printf("Enter the second string\n");

gets(s2);

strcat(s1,s2);

printf("\n the concatenated string\n");

printf("%s",s1);

getch();

}

Output : Enter the first string: PRIST

Enter the second string: University

The concatenated string: PRIST University

Result:

Thus the „C‟ program to concatenate two strings was implemented.

Page 54: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

52 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:15: PRIME NUMBER

Aim :

To create a “C” program to check the given number is prime or not

Algorithm :

1. Start the program

2. Read the value for “n”

3. Assign i = 1 and c = 0

4. Repeat the step 5 to 7 until i<=n

5. Compute a = n % i

6. If (a=0) then increment the value of “c” as c = c + i

7. Compute i = i+1

8. If c=2 then print the given number is prime otherwise the given number is not

a prime

9. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

void main()

{

int n;

void prime(int n);

clrscr();

printf("enter the number to be checked:");

scanf("%d",&n);

prime(n);

getch();

}

void prime(int n)

{ int i,c=0,a;

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

{

a=n%i;

if(a==0)

{

c=c+1;

}

}

if(c==2)

{printf("The given numbers is prime");

}

else

{

printf("The given number is not prime");

} }

Page 55: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

53 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

Output :

Enter the number to be checked: 15

The given number is not prime

Result :

Thus the “C” program is created and verified that the given number is prime or

not using function.

Page 56: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

54 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO:16 FACTORIAL PROGRAM USING RECURSION

Aim:

To write a “C” program to find the factorial of a given number using recursive

function

Algorithm:

MAIN FUNCTION:

1. Start the program

2. Read the number “n”

3. Call the function program Fact(n)

4. Print fact

5. Stop the program

FACT FUNCTION:

If n = 1 then fact = 1 otherwise fact = n * fact (n – 1)

Return (Fact)

Program:

#include<stdio.h>

#include<conio.h>

long fact(int n); /*function declaration*/

void main()

{

int num;

long fact1;

clrscr();

printf("\nEnter a number");

scanf("%d",&num);

fact1=fact(num); /* function call*/

printf("The factorial of %d is %d",num,fact1);

getch();

}

/*Function definition*/

long fact(int n)

{

if(n==1|n==0)

return(1);

else

return(n*fact(n-1));

}

Output :

Enter a number5

The factorial of 5 is 120

Result :

Thus “C” program was created and to find the factorial of a given number using

recursive function

Page 57: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

55 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

EX.NO: 17 GENERATE MARK SHEET USING STRUCTURE

Aim :

To write a “C” program to print the mark sheet of “N” students using structures

Algorithm :

1. Start the program

2. Declare the structure as students with the fields of name , rollno , m1 , m2 ,

m3 and total

3. Read the value of num

4. Assign i = 0

5. Repeat the steps 6 to 8 until i < num

6. Read the value of s1[i].rollno , s1[i].name , s1[i].m1 , s1[i].m2 , s1[i].m3

7. Compute s1[i].total = s1[i].m1 + s1[i].m2 + s1[i].m3

8. Compute i = i + 1

9. Print the detail of mark list

10. Assign i = 0 and repeat step 11 and 12 until i < num

11. Print s1[i].rollno , s1[i].name , s1[i].m1 , s1[i].m2 , s1[i].m3 , s1[i].total

12. Compute i = i + 1

13. Stop the program

Program :

#include<stdio.h>

#include<conio.h>

struct student

{

char name[10][10];

int rollno,m1,m2,m3,total;

};

void main()

{

int n,i,j;

struct student s[10];

clrscr();

printf("\n Enter the no.of students\n");

scanf("%d",&n);

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

{

printf("\n Enter the roll number:\t");

scanf("%d",&s[i].rollno);

printf("\n Enter the Name:\t");

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

printf("\n Enter the mark 1:\t");

scanf("%d",&s[i].m1);

printf("\n Enter the mark 2:\t");

scanf("%d",&s[i].m2);

Page 58: Computer Practice Lab Manual

13150L16/Computer Practice Lab I year/I Sem

56 Prepared by R.Bhavani, D.Vinotha & S.Sathish Kumar

printf("\n Enter the mark 3:\t");

scanf("%d",&s[i].m3);

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

}

printf("\n The details of the mark sheet is as follows\n");

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

{

printf("\nRoll number:\t%d",s[i].rollno);

printf("\nName:\t%s",s[i].name);

printf("\nMark 1:\t%d",s[i].m1);

printf("\nMark 2:\t%d",s[i].m2);

printf("\nMark 3:\t%d",s[i].m3);

printf("\nTotal:\t%d",s[i].total);

}

getch();

}

Output :

Enter the no.of students 2

Enter the roll number: 001

Enter the Name: HARI

Enter the mark 1: 98

Enter the mark 2: 87

Enter the mark 3: 89

Enter the roll number: 002

Enter the Name: SIVA

Enter the mark 1: 89

Enter the mark 2: 87

Enter the mark 3: 85

The details of the mark sheet is as follows

Roll number: 1

Name: HARI

Mark 1: 98

Mark 2: 87

Mark 3: 89

Total: 274

Roll number: 2

Name: SIVA

Mark 1: 89

Mark 2: 87

Mark 3: 85

Total: 261

Result: Thus “C” program to print the mark sheet of “N” students using structures was

executed.