Top Banner
COMPUTER PRACTICE- I LAB MANUAL PERI Institute of Technology, Mannivakkam, Chennai-48 Page 1
104
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Full Lab Manua1 - I Sem With Answersl

COMPUTER PRACTICE- I

LAB MANUAL

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 1

Page 2: Full Lab Manua1 - I Sem With Answersl

LIST OF EXERCISES

a) Word Processing

1. Document creation, Text manipulation with Scientific notations.

2. Table creation, Table formatting and Conversion.

3. Mail merge and Letter preparation.

4. Drawing - flow Chart

b) Spread Sheet

5. Chart - Line, XY, Bar and Pie.

6. Formula - formula editor.

7. Spread sheet - inclusion of object, Picture and graphics, protecting the

Document and sheet.

8. Sorting and Import / Export features.

Simple C Programming

9. Data types, Expression Evaluation, Condition Statements.

10. Arrays

11. Structures and Unions

12. Functions

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 2

Page 3: Full Lab Manua1 - I Sem With Answersl

MICROSOFT

WORD

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 3

Page 4: Full Lab Manua1 - I Sem With Answersl

MICROSOFT WORD

Word processor is used to produce documents for business or personal use

such as newsletter, reports, letters and essays. We might say that a word processor

is an intelligent typewriter. We can type a whole page, make corrections (editing),

use up paragraphs in different styles and shapes and columns (formatting) and also

check spelling, find and insert synonyms for a word (Thesaurus) and process it in

many more ways before we actually put that page to print.

FEATURES OF WORD PROCESSOR

The following are the main features of a word processor:

Fast

Editing features

Permanent storage

Formatting features

Graphics

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 4

Page 5: Full Lab Manua1 - I Sem With Answersl

Ex:No:1 DOCUMENT CREATION, TEXT MANIPULATIONDate : SCIENTIFIC NOTATIONS

AIM:

To prepare an advertisement and to insert a formula using the various formatting option and symbols available in MS-word.

PROCEDURE:

a) Advertisement-1

Step 1: Open a new document using File-> new option and type text.

Step 2: Place the different sized boxes in the document from the drawing toolbar

Step 3: Type the text in the boxes.

Step 4: Fill the boxes with black color using fill color option from the drawing toolbar

Step 5: Place the appropriate logo from the insert->picture->from file option

Step 6: Choose the appropriate ward art gallery to place the text in boxes

Step 7: Choose the bullets for the text from the for matting toolbar.

Step 8: Use all these options to create an advertisement as specified in exercise.

b) Equations

Step 1: Enter the equation in the document.

Step 2: Select the character, which you want to show as a sub script

Step 3: For subscript, choose the font option from the format menu, then enable the superscript

Thick box from the font dialog box.

Step 4: For superscript, choose the font option from the format menu, then enable the superscript

Thick box from the font dialog box.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 5

Page 6: Full Lab Manua1 - I Sem With Answersl

c) Inserting symbols

Step 1: Type the text, then put the cursor where you want to add the symbol

Step 2: Choose symbols option from the insert menu.

Step 3: Shows the symbols dialog box. Then choose the appropriate font type.

Step 4: Then choose required symbol from the symbols dialog box, then click.

d) Creating Resume

Step 1: Open a new document using File-> new option, new document dialog box opened .

Step 2: In the Template tab, Click Resumes option

Step 3: Select the sample Resumes, and update the data accordingly

Step 4: Then save the resume using save as option in the save the document.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 6

Page 7: Full Lab Manua1 - I Sem With Answersl

OUTPUT:

DOCUMENT CREATION & INSERTING SYMBOLS

TEXT MANIPULATION WITH SCIENTIFIC NOTATION

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 7

Page 8: Full Lab Manua1 - I Sem With Answersl

RESUME

Name

Address Contact details with corresponding symbols

Objectives:

Educational Qualification:

Extra curricular activities:

Co-curricular activities:

Hobbies:

Personal profile:

Declaration:

Thanking you,

Yours truly,

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 8

Page 9: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the advertisement has been created and the given formula has been included also resume has been prepared using Ms Word.

Ex:No:2 TABLE CREATION, TABLE FORMATTING ANDCONVERSION

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 9

Page 10: Full Lab Manua1 - I Sem With Answersl

Date :

AIM:

To create a table for the given data and utilize all the available options in the word processor.

PROCEDURE:

a) For table insertion

Step 1: Choose table -> Insert -> Table option.

Step 2: It shows the insert table dialog box.

Step 3: Then choose the required number of Columns and Row.

Step 4: Then click ok to add table in your document.

Step 5: The type the text in each column.

Step 6: Press TAB key to move the cursor from one cell to another.

b) For table formatting

Step 1: Select table menu bar, then choose insert table option

Step 2: It shows the insert table dialog box.

Step 3: Set of columns to 5, Number of Rows to 4 and column width in the insert table dialog

Box and click.

Step 4: Now the table is inserted in the document with 5 columns and 4 rows.

c) Auto formatting the table

Step 1: Select the table in the document.

Step 2: Choose table Auto Format option in the table menu

Step 3: Now it shows the table Auto Format dialog box.

Step 4: Choose the required Format from the Format list box. Then click ok.

Step 5: Now the specified Format is applied to the table.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 10

Page 11: Full Lab Manua1 - I Sem With Answersl

d) Converting the table to text

Step 1: Select a table in a document.

Step 2: Choose the convert table to text option from the table menu.

Step 3: Now it shows the convert table to text dialog box.

Step 4: Choose the separator of the text. Then click ok.

Step 5: Now the table in formation is converted into text in a document.

e) Convert the text to table

Step 1: Select the text in the document

Step 2: Select the convert text to table option from the table menu.

Step 3: Now the convert text to table dialog box.

Step 4: Choose the table size and separator text option then dialog box click on ok.

Step 5: Now the text information is converted into a table.

OUTPUT:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 11

Page 12: Full Lab Manua1 - I Sem With Answersl

TABLE CREATION

DAYS

1 2 3 4 5 6 7 8

8:15 –

9:05

9:05 –

9:55

10:05- 10:55

10:55 -11:45

11:45- 12:35

12:35 1:25

1:25 – 2:15

2:25 –3:15

3:15 - 4:05

MON

LUNCH

TUE

WED

THU

FRI

DAYS

1 2 3 4 5 6 7 8

8:15 –

9:05

9:05 –

9:55

10:05- 10:55

10:55 -11:45

11:45- 12:35

12:35 1:25

1:25 – 2:15

2:25 –3:15

3:15 - 4:05

MON

LUNCH

TUECP1 LAB : A

WED

THUCP1 LAB : B

FRI

TABLE FORMATTING

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 12

Page 13: Full Lab Manua1 - I Sem With Answersl

CONVERTING THE TABLE TO TEXT

CONVERTING TEXT TO TABLE

RESULT

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 13

Page 14: Full Lab Manua1 - I Sem With Answersl

Thus the table has been created for the given data and also converted from text to table & table to text using Ms word processor.

Ex:No:3 MAIL MERGE

Date :

AIM:

To illustrate the concept of mail merge in word processor.

PROCEDURE:

Creating the main Document

Step 1: Select file option in the menu bar and click. New to open a new document.

Step 2: From the tools menu select the mail merge

Step 3: It shows the mail main document area of mail merge helper dialog box, click on create

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 14

Page 15: Full Lab Manua1 - I Sem With Answersl

Button, it shows the available options.

Step 4: Select form letters from the pull down menu of create button

Step 5: Click active window button in Microsoft word dialog box.

Creating a Data Source

Step 1: In the mail merge helper dialog box, click get data button.

Step 2: Select create data source to get create data source dialog box.

Step 3: Select the appropriate fields from the field names in header row and drop down list box

Or add new fields by typing the field name box and click on add field name.

Step 4: Remove the unwanted field by clicking the remove field name.

Step 5: Click ok. Now the save as dialog box appears to save the data source.

Step 6: Type the appropriate name for the data source the click ok.

Step 7: It dialog box asking to and records to data base in the following dialog box.

Step 8: Click on edit data source to add records to the data source.

Step 9: In shows the data from dialog box, add records to the data source.

Step 10: Then the click ok, the mail merge tool bars is automatically displayed in the main

Document

Creating the merged document

Step 1: Click on the insert merge field on the mail merge tool bar.

Step 2: Selected the desired fields from the drop down menu of insert merge field.

Step 3: After inserting the merge fields, choose tools->mail merge.

Step 4: Mail merge helper dialog box shows, from this dialog box, Click merge the click on

Merge button, to create a new document. New the main document and data source is

Merged into new document.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 15

Page 16: Full Lab Manua1 - I Sem With Answersl

OUTPUT:

Using mail merge send the following letter to 5 of your friends.

From

Anto,B-62,13th cross street,Rose apartments,Ambattur,Chennai.

To

<<friend Name>>

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 16

Page 17: Full Lab Manua1 - I Sem With Answersl

<<Address>>

Dear <<friend name>>,

Sub: Invitation for party.

I hereby invite you and your family members for the 25th anniversary of my

parents that is to be held on 28-11-2008 at our home. Please do come and share

with us our joy. I will be disappointed in your absence.

Yours lovingly,

Anto

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 17

Page 18: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the concept of mail merge has been illustrated successfully in the word processor.

Ex:No:4 DRAWING FLOWCHART

Date :

AIM:

To draw the given flowchart utilizing the various auto shapes in word processor.

PROCEDURE:

a) Drawing

Step 1: Choose the up ribbon option in the starts and banners of the auto shapes menu in the

Drawing tool bar.

Step 2: Draw the required size of up ribbon in the document.

Step 3: Click on the insert word action in the drawing tool.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 18

Page 19: Full Lab Manua1 - I Sem With Answersl

Step 4: Now the word art gallery dialog box is shown with different style.

Step 5: Choose the required style, and then click ok.

Step 6: Now the edit word art text box, dialog box.

Step 7: Type the text then click on ok.

Step 8: place the text in the up ribbon.

b) Flow Chart

Step 1: Choose flow chart option in the auto shapes menu of the drawing tool bar.

Step 2: Choose the appropriate flowchart symbol, and then drag the symbol in the document

Step 3: Type the text in the symbol by right click then choose add text.

Step 4: Using the flow button, line style button, Arrow style in the drawing tool bar draw the

lines Connecting to the different flow chart symbols.

Step 5: Select all the flow chart symbols and lines in the document using the select object button,

Then right choose grouping, then click on group.

Step 6: Now all the flow chart symbols are grouped into one.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 19

Page 20: Full Lab Manua1 - I Sem With Answersl

DRAWING A FLOW CHART

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 20

Page 21: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the given flowchart has been created in the word processor.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 21

Page 22: Full Lab Manua1 - I Sem With Answersl

MICROSOFT

EXCEL

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 22

Page 23: Full Lab Manua1 - I Sem With Answersl

MS-EXCEL

An electronic spreadsheet or spreadsheet is a table of rows and

columns into which data is entered. Spreadsheet software makes it

possible to enter data into a task format, manipulate, store, print and

create reports and graphics using them.

Microsoft Excel is the most widely used and versatile spreadsheet

package and lets you to organize your data into lists and then

summarize, compare and present the data graphically. It has the user

interface features common to other Microsoft office applications.

MS-EXCEL allows you to

Enter and edit data in a worksheet

Use functions and formulae to calculate and analyze data

Create colorful charts and graphs

Save time by combining a series of commands into a single

command by using MACROS

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 23

Page 24: Full Lab Manua1 - I Sem With Answersl

Ex:No:5 CHART CREATION

Date :

AIM:

To created the student mark list and find to total, average and grade using the formula editor and to insert the appropriate chart in spread sheet.

PROCEDURE:

Step 1: Enter the student name, marks in three subject.

Step 2: Place the cursor in E2, type=sum (B2-D2)

Step 3: Place the cursor in f2, type=AVERAGE (B2-D2)

Step 4: Click on G2, type

If (OR (B2<35, C2<35, D2<35), “FAIL”,

IF (F2>=75, “DISTINCTION”, IF (F2>=60, “FIRST CLASS”, IF (F2>=50

“SECOND CLASS”, THIRD CLASS”))))

Step 5: Copy the formula to the remaining students.

Step 6: Finally the worksheet is follows.

LINE CHART

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 24

Page 25: Full Lab Manua1 - I Sem With Answersl

BAR CHART

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 25

Page 26: Full Lab Manua1 - I Sem With Answersl

PIE CHART

XY CHART

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 26

Page 27: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the student mark list has been prepared along with the chart.

Ex:No:6 FORMULA EDITOR

Date :

AIM:

To calculate HRA, DA, TA, PF, GPF, LIC, Gross salary, Deductions, Net salary from the given data in a

worksheet.

ENO Name Basic HRA TA DA LIC PF GPF GS DED NET

1 RAJ 20000

2 RAVI 15000

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 27

Page 28: Full Lab Manua1 - I Sem With Answersl

3 MUTHU 10000

4 SANGEETHA 7820

5 RAMANI 4569

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

GS (Gross salary) =Basis+HRA+DA+TA

DED (Deduction) =PF+GPF+LIC

NET (Net salary) =GS-DED

PROCEDURE:

Step 1: To enter Microsoft Excel, Click “start” button then click “program” from

“programs” menu then click “Microsoft Excel”

Step 2: For opening a word document do the following. Click “file” menu from the

menu bar. From this file menu click “new” option. This will display the new

work sheet.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 28

Page 29: Full Lab Manua1 - I Sem With Answersl

Step 3: Enter the data by placing the mouse pointer in a cell and a double click on

it. Use the tab key to switch from one cell to another.

Step 4: For putting formulas, for eg,place the cursor on a cell which you have to

calculate the value of HRA, then type =cell position of basic*18% and

press enter. Now the value of HRA is calculated. Similarly do for all others.

Step 5: Calculate the same for other columns and drag them to all the cells.

Step 6: Now the entire table is ready in spreadsheet.

OUTPUT:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 29

Page 30: Full Lab Manua1 - I Sem With Answersl

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 30

Page 31: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the formula editing using excel sheet to calculate HRA, DA, TA, PF,

GPF, LIC, Gross salary, Deductions, Net salary from the given data is completed.

Ex: No: 7 INCLUSION OF OBJECT, PICTURE & GRAPHICS

Date: AIM:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 31

Page 32: Full Lab Manua1 - I Sem With Answersl

i. To Insert object in the worksheet

ii. To Insert picture in the worksheet

iii. To Protect a sheet

PROCEDURE:

Step 1: To enter Microsoft Excel, Click “start” button then click “program” from

“programs” menu then click “Microsoft Excel”.

Step 2: For opening a word document do the following. Click “file” menu from the

menu bar. From this file menu click “new” option. This will display the new

work sheet.

Step 3: For inserting object in the worksheet, choose objects option in the insert

menu.

Step 4:For inserting picture in the worksheet, choose Picture option in the insert

menu.

Step 5: For protecting your worksheet, choose Protection option from Tools menu,

then choose Protect Sheet option, Protect sheet dialog box appears. Type a

password and press enter.

Step 6: Now your worksheet is protected and can be entered only with the

password.

INCLUSION OF OBJECT

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 32

Page 33: Full Lab Manua1 - I Sem With Answersl

INCLUSION OF PICTURE

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 33

Page 34: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the given objects has been included in the spread sheet.

Ex: No:8 SORTING AND IMPORT/EXPORT FEATURES

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 34

Page 35: Full Lab Manua1 - I Sem With Answersl

Date:

AIM:

i. To sort the given data in the worksheet

ii. To include Import/export features

PROCEDURE:

Step 1: To enter Microsoft Excel, Click “start” button then click “program” from

“programs” menu then click “Microsoft Excel”.

Step 2: For opening a word document do the following. Click “file” menu from the

menu bar. From this file menu click “new” option. This will display the new

work sheet.

Step 3: Select the data to be sorted and select data from the menu and click sort.

Step 4:Specify the order in which the data are to be sorted (ascending or

descending) and click OK. Then the sorted data appears in the sheet.

Step 5: To import a file select Insert->object->create from file.

Step 6: To export a file while saving the file save it as webpage so that it can be

viewed by internet explorer.

OUTPUT:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 35

Page 36: Full Lab Manua1 - I Sem With Answersl

Sort the given data in ascending and descending order (consider the name).

NAME MARK1 MARK2 MARK3Anto 96 85 45

Ignatius 80 59 85Griffin 78 89 45Mary 90 85 89Herin 82 96 81Ram 73 52 99Devi 76 90 86

ASCENDING ORDER

DESCENDING ORDER

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 36

Page 37: Full Lab Manua1 - I Sem With Answersl

IMPORTING A FILE

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 37

Page 38: Full Lab Manua1 - I Sem With Answersl

EXPORTING A FILE

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 38

Page 39: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the sorting and import and export features using Ms excel is completed.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 39

Page 40: Full Lab Manua1 - I Sem With Answersl

C PROGRAMMING

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 40

Page 41: Full Lab Manua1 - I Sem With Answersl

INTRODUCTION TO C PROGRAMMING:

C is a structured language.

A structured language allows variety of programs in small modules.

It is easy for debugging, testing and maintenance.

C is an imperative (procedural) systems implementation language.

It was designed to be compiled using a relatively straight forward compiler, to

provide low level access to memory, to provide language constructs that map

efficiently to machine instruction and to require minimal run–time support.

A program is a set of instructions for performing a particular task. This

written program is called as source program.

The source program to be converted to the machine language. Which is called

as object program. Either Interpreter or Compiler will perform this function.

An Interpreter reads only one line of a source program at a time and

converts it to object code. Error will be indicated instantly.

A Compiler reads the entire program and converts it to the object code. It

provides the error not one but errors of the entire program.

Ex:No:9 FINDING THE SIZE OF VARIBLES

Date :

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 41

Page 42: Full Lab Manua1 - I Sem With Answersl

AIM:

To write a c program to find the illustrate size of the variables.

ALGORITHM:

Step 1: Start

Step 2: Read the input values of num, dec, ext, ltr, str.

Step 3: Print size of num

Step 3.1: Print size of dec

Step 4: Print size of ext

Step 5: Print size of ltr

Step 6: Print size of str

Step 7: Stop

PSEUDOCODE:

Set initial num, dec, ext, ltr, str

READ the values of num, dec, ext, ltr, str

WRITE the size of num, dec, ext, ltr, str

Stop

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 42

Page 43: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 43

Start

Read num, dec, ext, ltr, str

Print size of dec

Print size of ext

Print size of ltr

Print size of str

Stop

Print size of num

Page 44: Full Lab Manua1 - I Sem With Answersl

#include<stdio.h>

#include<conio.h>

void main()

{

int num=12345;

float dec=0.123456;

double ext=1234567890;

char ltr='A';

char str[]="this is computer pratice lab";

clrscr();

printf("size of the integer %d is %d bytes/n",num,sizeof(num));

printf("size of the float %f is %d bytes/n",dec,sizeof(dec));

printf("size of the double %lf is %d bytes/n",ext,sizeof(ext));

printf("size of the char %c is %d bytes/n",ltr,sizeof(ltr));

printf("size of the string %s is %d bytes/n",str,sizeof(str));

getch();

}

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 44

Page 45: Full Lab Manua1 - I Sem With Answersl

OUTPUT:

Size of the integer 12345 is 2 bytes

Size of the float 0.123456 is 4 bytes

Size of the double 1234567890.000000 is 8 bytes

Size of the char A is 1 bytes

Size of the string this is computer practice lab is 29 bytes

RESULT:

Thus the program to find “size of variable” has been written and executed successfully.

Ex:No:10 TEMPERATURE CONVERSION

Date :

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 45

Page 46: Full Lab Manua1 - I Sem With Answersl

AIM:

To write a program in c to find centigrade and fahrenheit values

ALGORITHM:

Step 1: Start

Step 2: Read centigrade value to c

Step 3: Compute equivalent Fahrenheit value using formulae

F 1.8*c+32

Step 4: Print the value F

Step 5: Read Fahrenheit value to Fn

Step 6: Compute equivalent centigrade value using formulae

Cn= (Fn-32)/1.8

Step 7: Print the value of Cn

Step 8: Stop

PSEUDOCODE:

Set initial centigrade, Fahrenheit

READ the value of centigrade.

Calculate Fahrenheit = (1.8*centigrade) +32

WRITE the value of Fahrenheit

READ the value of Fahrenheit

Calculate centigrade = (fahrenheit-32)/1.8

WRITE Centigrade

Stop

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 46

Page 47: Full Lab Manua1 - I Sem With Answersl

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 47

Start

Read c

F1.8*c+32

Print F

Read Fn

Cn (Fn-32)/1.8

Print Cn

Stop

Page 48: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

#include<stdio.h>

#include<conio.h>

void main()

{

float c,f,cn,fn;

clrscr();

printf("Enter the temperature in centigrade:");

scanf("%f",&c);

f=1.8*c+32;

printf("Fahrenheit equivalent is:%lf/n",f);

printf("Enter the temperature in fahreheit:");

scanf("%f",&fn);

cn=(fn-32)/1.8;

printf("Centigrade equivalent is:%lf/n",cn);

getch();

}

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 48

Page 49: Full Lab Manua1 - I Sem With Answersl

OUTPUT:

Enter the temperature in centigrade: 20

Fahrenheit equivalent is: 68.0

Enter the temperature in Fathrenheit: 68

Centigrade equivalent i

RESULT:

Thus the program for “temperature of conversion” has been written and execute successfully.

Ex:No:11 AREA OF TRIANGLE

Date :

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 49

Page 50: Full Lab Manua1 - I Sem With Answersl

AIM:

To write a program in C to find the area of a given triangle of sides a, b, c.

ALGORITHM:

Step 1: Start

Step 2: Read the input values of sides of a triangle a, b, c.

Step 3: Compute s = (a+b+c)/2

Step 4: Compute d = (s*(s-a)*(s-b)*(s-c))

Step 5: Compute the area of triangle area = sqrt (d)

Step 6: Print area

Step 7: Stop.

PSEUDOCODE:

Set initial a, b, c.

READ the value of a, b, c.

To calculate three sides of triangle using formula s = (a+b+c)/2.

To find area of a triangle using formula

Area = sqrt (s*(s-a)*(s-b)*(s-c)).

WRITE the output area.

Stop.

FLOWCHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 50 Start

Read a, b, cPrint area s (a+b+c)/2

d             (s*(s-a)*(s-b)*(s-c))Area   sqrt (d)

          Stop

Page 51: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

#include<stdio.h>

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 51

Page 52: Full Lab Manua1 - I Sem With Answersl

#include<conio.h>

#include<math.h>

void main()

{

int a,b,c;

float s,d,area;

clrscr();

printf("Enter the 3 sides:");

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

s=(a+b+c)/2;

d=(s*(s-a)*(s-b)*(s-c));

area=sqrt(d);

printf("Area of triangle=%f sq units/n",area);

getch();

}

OUTPUT:

Enter the three sides: 5 6 7

Area of triangle = 14.696939sq units.

RESULT:

Thus the program for the construction of “Area of triangle” has been written and executed successfully.

Ex:No:12 SUM OF SERIES

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 52

Page 53: Full Lab Manua1 - I Sem With Answersl

Date :

AIM:

To write a program in c to find sum of the series 1+(1+2)+(1+2+3)+……n.

ALOGRITHM:

Step 1: Start

Step 2: Read the value of n

Step 3: Initialize value for i=1, s=0

Step 4: Check whether the value of i is less than or equal to value of n.

Step 5: Repeat for i=1 to n.

Step 6: Initialize values for term=0, j=1

Step 7: Repeat for j=1 to i

Step 8: Compute the value term= term+j

Step 9: Increment j by 1

Step 10: End of step 7

Step 11: Compute S=S+term

Step 12: Increment I by 1

Step 13: Print the value of s

Step 14: Stop

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 53

Page 54: Full Lab Manua1 - I Sem With Answersl

PSEUDOCODE:

Set initial i, j, h

READ the value of n

Assign I=1, s=0

For (i1; i<=n; i++)

Assign j=1, term=0

Repeat for j=1 to i

Calculate term= term+j

Then compute S=s+term

WRITE the value of S

Stop

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 54Start

Page 55: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 55

Read a

Term 0

For i1;i<=n;i++

For j1;j<=I;j++

Term term +j

S S+term

Print S

Stop

Page 56: Full Lab Manua1 - I Sem With Answersl

#include<stdio.h>

#include<conio.h>

Void main()

{

int I, j, n, s, term;

clrscr();

printf(“Enter the value n:”);

scanf(“%d”,&n);

s=0;

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

{

term=0;

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

{

term=term+j;

}

s=s+term;

}

printf(“Sum of the series s=%d”,s);

getch();

}

OUTPUT:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 56

Page 57: Full Lab Manua1 - I Sem With Answersl

Enter the value n: 4

Sum of the series S=20

RESULT:

Thus the program for the construction of the sum of series has been written and executed successfully

Ex:No: 13 ELECTRICITY BILL PREPARATION

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 57

Page 58: Full Lab Manua1 - I Sem With Answersl

Date :

AIM:

To write a program for electricity bill preparation using the various basic data types.

ALGORITHM:

Step 1: Start

Step 2: Read srl no, recpt no, bill month, date.

Step 3: Read present and previous meter readings.

Step 4: Consumed=Present-Previous

Step 5: Check if consumed>=200

Step 5.1: Total=Consumed*2.50 else

Step 5.2: Total=Consumed*1.50

Step 6: Print srl no, recpt no, bill month, date.

Step 7: Print Consumed total

Step 8: Stop

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 58

Page 59: Full Lab Manua1 - I Sem With Answersl

PSEUDOCODE:

Set initial srl no, recpt no, bill month, date, present, previous.

READ Srl no, recpt no, bill month, date, present, previous.

Consumed=Present-Previous

if (consumed>=200)

Total=consumed*2.50

Else

Total=consumed*1.50

End if

WRITE

Srl no, recpt no, bill month, date, consumed, total.

Stop.

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 59

Start

Page 60: Full Lab Manua1 - I Sem With Answersl

Yes

No

PROGRAM:

#include<stdio.h>

#include<conio.h>

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 60

Read srl no, recpt no, bill month, date, present, previous

Consumed= Present-Previous

If Consumed>=200

Total = Consumed*2.50

Total= Consumed *1.50

Print srl no, recpt no, bill month, date, consumed, total

Stop

Page 61: Full Lab Manua1 - I Sem With Answersl

void main()

{

int present,previous,consumed,srlno;

char name[20],rcptno[10],billmonth[15],date[12];

float total;

clrscr();

printf("/nEnter Serial No&Recipt No:");

scanf("%d%s",&srlno,rcptno);

printf("/nEnter Bill Month&Date:");

scanf("%s%s",billmonth,date);

printf("/nPresent&Previous readings:");

scanf("%d%d",&present,&previous);

consumed=present-previous;

if(consumed>=200)

total=consumed*2.50;

else

total=consumed*1.50;

printf("/n/t/t/tELECTRICITY BILL\n");

printf("/t/t/t...............\n");

printf("SCNO. :%d/t/t/t/tReceiptNo.:%s/n",srlno,rcptno);

printf("BILL MONTH:%s\t\t\tDate:%s\n",billmonth,date);

printf("/n Total cost for consumed %d unit is RS:%f",consumed,total);

getch();

}

OUTPUT:

Enter Serial No&Receipt No:128 AC1237

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 61

Page 62: Full Lab Manua1 - I Sem With Answersl

Enter Bill Month&Date:10/2010

25-11-2010

Present&Previous readings:980 520

ELECTRICITY BILL

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

SC NO: 128 Receipt No: AC1237

Bill Month: 10/2010 Date: 25.11.2010

Total cost for consumed 460 unit is Rs: 1150.000000

RESULT:

Thus the program for electricity bill preparation has been written and executed successfully

Ex:No:14 MAXIMUM OF THREE NUMBERS

Date :

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 62

Page 63: Full Lab Manua1 - I Sem With Answersl

AIM:

To write a program to print maximum value of given 3 numbers.

ALGORITHM:

Step 1: Start

Step 2: Read the input values a, b, c.

Step 3: Call and print the function maximum ( ) with parameters a, b, c.

Step 4: Stop

Maximum (x, y, z)

X, y, z integer

Step 1: initialize max= x

Step 2: Check whether the value of y is greater than the value of max.

Step 3: If step- 2 is true, assign max= y

Step 4: Check whether the value of z is greater than the value of max.

Step 5: If step- 4 is true, assign max= z

Step 6: Return the value of max to main program.

PSEUDOCODE:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 63

Page 64: Full Lab Manua1 - I Sem With Answersl

Set initial a, b, c

READ the value for a, b, c

If (a> b and a> c) THEN

WRITE ‘A is big’

Else if (b>c) THEN

WRITE ‘B is big’

Else

WRITE ‘C is big’

Stop.

FLOWCHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 64

Start

Page 65: Full Lab Manua1 - I Sem With Answersl

Yes

No

Yes

No

PROGRAM:

#include<stdio.h>

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 65

Read a, b, c

Call and print maximum (a, b, c)

Max  x

If y > max

Stop

Maximum (x, y, z)

If z > max

Max  x z

Max  x y

Return max

Page 66: Full Lab Manua1 - I Sem With Answersl

#include<conio.h>

void main()

{

int a,b,c;

clrscr();

printf("Enter three integers:");

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

printf("Maximum is:%d\n",max(a,b,c));

getch();

}

int max(int x,int y,int z)

{

int max=x;

if(y>max)

max=y;

if(z>max)

max=z;

return max;

}

OUTPUT:

Enter three integers: 269 312 456

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 66

Page 67: Full Lab Manua1 - I Sem With Answersl

Maximum is: 456

RESULT:

Thus the C program for finding the value of given three integer has been written and executed successfully.

Ex:No:15 FACTORIAL

Date :

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 67

Page 68: Full Lab Manua1 - I Sem With Answersl

AIM:

To write a program in C to find the Factorial of the given number

ALGORITHM:

Step 1: Start

Step 2: Read input value n

Step 3: Call and Print function fact (n)

Step 4: Stop

Step 1: Function fact start

Step 2: In n=0 returns 1 else go to step 3

Step 3: return (n*Fact (n-1))

PSEUDOCODE:

Set initial n

READ the value of n

If (n==0)

WRITE the value 1

Else

Calculate Fact (n) = (n*Fact(n-1))

WRITE the output Fact (n)

END IF

Stop

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 68

Page 69: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

#include<stdio.h>

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 69

Start

Read (n)

Call and Print

Fact (n)

Stop

Fact (n)

If n=0

Return (n*Fact (n-1))

Return 1

Page 70: Full Lab Manua1 - I Sem With Answersl

#include<conio.h>

void main()

{

int n;

long int fact();

clrscr();

printf("Enter the number whose factorial is to be found:");

scanf("%d",&n);

printf("the factorial of %d is:%d/n",n,fact(n));

getch();

}

long int fact(n)

int n;

{

if(n==0)

return(1);

else

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

}

OUTPUT:

Enter the number whose factorial is to be found: 6

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 70

Page 71: Full Lab Manua1 - I Sem With Answersl

The factorial of 6 is: 720

RESULT:

Thus the C program finding the “Factorial” has been written and executed successfully.

Ex:No:16 MATRIX ADDITION

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 71

Page 72: Full Lab Manua1 - I Sem With Answersl

Date :

AIM:

To write a program to print sum of the matrix

ALGORITHM:

Step 1: Start

Step 2: Read rows and columns of matrix A and B into n, m, p, q

Step 3: Check the values of n is equal to p and m is equal to q

Step 4: If step 3 is true. Do step 5 to step 20

Step 5: Repeat for i=0 to n

Step 6: Repeat for j=0 to m

Step 7: Read into a[i][j]

Step 8: End of step 6

Step 9: End of step 5

Step 10: Repeat for i=0 to p

Step 11: Repeat for j=0 to q

Step 12: Read into b[i][j]

Step 13: End of step 11

Step 14: End of step 10

Step 15: Repeat for i=0 to n

Step 16: Repeat for j=0 to m

Step 17: Add a[i][j], b[i][j], c[i][j]

Step 18: Print c[i][j]

Step 19: End of step 16

Step 20: End of step 15

Step 21: If step 3 is false, print “Addition is not possible”.

Step 22: Stop

PSEUDOCODE:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 72

Page 73: Full Lab Manua1 - I Sem With Answersl

Set initials n, m, p, q, a[i][j], b[i][j], c[i][j].

READ the values of n, m, p, q

If (n==p) && (m==q)) then

For (i0; i<n; i++)

For (j0; j<m; j++)

READ a[i][j] and b[i][j]

END FOR

Calculate (c[i][j]= a[i][j]+b[i][j])

For (i0; i<n; i++)

For (j0; j<m; j++)

READ a[i][j] and b[i][j]

END FOR

Calculate (c[i][j]=a[i][j]+b[i][j])

For (i0; i< n; i++)

For (j0; j<m; j++)

WRITE the output c[i][j]

END FOR

ELSE

WRITE ‘Addition is not possible’

END IF

Stop

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 73

Page 74: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 74

Start

Read n, m, p, q

If n=p&&m=q

For i0;i<n;i++

For j0;j<m;j++

Read a[i][j], b[i][j]

C[i][j]=a[i][j]+b[i][j]

Print Addition not possible

For i0; i<n; i++

For j0; j<m; j++

Print c[i][j]

Stop

Page 75: Full Lab Manua1 - I Sem With Answersl

#include<stdio.h>

#include<conio.h>

void main()

{

int a[10][10],b[10][10],c[10][10];

int i,j,m,n,p,q;

clrscr();

printf("Enter the row and column of A matrix:");

scanf("%d%d",&n,&m);

printf("Enter the row and column of B matrix:");

scanf("%d%d",&p,&q);

if((n==p)&&(m==q))

{

printf("Matrices can be added\n");

printf("Enter the element of A matrix:\n");

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

for(j=0;j<m;++j)

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

printf("Enter the element of B matrix:\n");

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

for(j=0;j<m;++j)

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

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

for(j=0;j<m;++j)

c[i][j]=a[i][j]+b[i][j];

printf("sum of A and B matrix:\n");

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 75

Page 76: Full Lab Manua1 - I Sem With Answersl

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

{

for(j=0;j<m;++j)

printf("%5d",c[i][j]);

printf("\n");

}

getch();

}

else

printf("Matrices cannot be added\n");

}

OUTPUT:

Enter the row and column of A matrix: 3 3

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 76

Page 77: Full Lab Manua1 - I Sem With Answersl

Enter the row and column of B matrix: 3 3

Matrices can be added

Enter the element of A matrix:

1 1 1

2 2 2

3 3 3

Enter the element of B matrix:

3 3 3

2 2 2

1 1 1

Sum of A and B matrix:

4 4 4

4 4 4

4 4 4

Enter the row and column of A matrix: 2 2

Enter the row and column of B matrix: 3 3

Matrices cannot be added

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 77

Page 78: Full Lab Manua1 - I Sem With Answersl

RESULT:

Thus the C program for finding the sum of the two matrices has been written and executed successfully.

Ex:No:17 STUDENT MARKLIST USING STRUCTURE

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 78

Page 79: Full Lab Manua1 - I Sem With Answersl

Date :

AIM:

To write a C program print student using structure.

ALGORITHM:

Step 1: Start

Step 2: Define structure stud with member

Roll no; integer

Name [30]; character

Mark 1, mark 2, mark 3, total: integer

Avg: total/3

Grade: character

End stud

Step 3: read input n

Step 4: set a loop to get record details

Step 5: Read a[i], roll no, a[i].name

Step 6: a[i].mark 1, a[i].mark 2, a[i].mark 3

Step 7: a[i].total=a[i].mark 1+ a[i].mark 2+ a[i].mark 3

Step 8: a[i].avg=a[i].total/3

Step 9: End of step 4

Step 10: Check if a[i]. avg<40 then assign a[i].grade=D

Step 11: Check if a[i].avg<60 then assign a[i].grade=C

Step 12: Check if a[i].avg<80 then assign a[i].grade=B else

Step 13: a[i].grade=’A’

Step 14: Print a[i].roll no, a[i].name, a[i].mark 1, a[i].mark 2, a[i].mark 3, a[i].total,

a[i].avg, a[i].grade.

Step 15: Stop.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 79

Page 80: Full Lab Manua1 - I Sem With Answersl

PSEUDOCODE:

Set initials structure of students

READ the roll no, name, mark 1, mark 2, mark 3, using structure variables

To calculate total=mark 1+mark 2+mark 3

Calculate average=total/3

If(average<40)

WRITE ‘Grade is D’

ELSE IF(average<80)

WRITE ‘Grade is B’

ELSE

WRITE ‘Grade is A’

END IF

WRITE the roll no, name, mark 1, mark 2, mark 3

WRITE the output total, avg, grade

Stop

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 80

Start

Page 81: Full Lab Manua1 - I Sem With Answersl

Yes

No

Yes

No

Yes

No

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 81

Struct Stud roll no: integer, name [30]: character, mark 1, mark 2, mark 3, total: integer, Avg: float, grade: character

Read n

For i=0; i<n; i++

Read a[i].rollno, a[i].name, a[i].mark 1, a[i].mark 2, a[i]. mark3

A[i].total=a[i].mark 1+a[i].mark 2+a[i].mark 3

If a[i]avg<40<40

If a[i]avg<60

Ifa[i] avg<80

A

a[i] grade= ’D’

a[i] grade= ‘C’

a[i] grade= ‘B’

A

Page 82: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

#include<stdio.h>

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 82

Print a[i].rollno, a[i].name, a[i].mark 1, a[i].mark 2, a[i]. mark3,a[i].total,a[i].avg,a[i].grade

A[i].grade=’A’

Stop

Page 83: Full Lab Manua1 - I Sem With Answersl

#include<conio.h>

struct stud

{

int rollno;

char name[30];

int m1,m2,m3,tot;

float avg;

char grade;

}

a[25];

void main()

{

int i,n;

clrscr();

printf("Enter the number of students:");

scanf("%d",&n);

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

{

printf("Enter the student %d details:",i+1);

printf("\nRollNo:");

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

printf("Name:");

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

printf("mark 1:");

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

printf("mark 2:");

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 83

Page 84: Full Lab Manua1 - I Sem With Answersl

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

printf("mark 3:");

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

a[i].tot=a[i].m1+a[i].m2+a[i].m3;

a[i].avg=a[i].tot/3;

if(a[i].avg<40)

a[i].grade='D';

else if(a[i].avg<60)

a[i].grade='C';

else if(a[i].avg<80)

a[i].grade='B';

else

a[i].grade='A';

}

printf("\t\tSTUDENTS MARK DETAILS:\n");

printf("\nRollno\tName\tmark 1\tmark 2\tmark 3\ttot\tAvg\tgrade\t");

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

printf("\n%d\t%s\t%d\t%d\t%d\t%d\t%.2f\t%c",a[i].rollno,a[i].name,a[i].m1,a[i].m2,a[i].m3,a[i].tot,a[i].avg,a[i].grade);

getch();

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 84

Page 85: Full Lab Manua1 - I Sem With Answersl

OUTPUT:

Enter the number of students: 2

Enter the student 1 details:

Roll No: 23

Name: ANU

Mark1: 89

Mark2:80

Mark3:76

Enter the student 2 details:

Roll No: 24

Name: BALU

Mark1: 69

Mark2:70

Mark3:71

STUDENT MARK DETAILS

Roll no Name Mark1 Mark2 Mark3 Total Average Grade

23 ANU 89 80 76 245 81.00 A

24 BALU 69 70 71 210 70.00 B

RESULT:

Thus the C program for the construction of mark details is written and executed successfully

Ex:No:18 PRINTING EMPLOYEE DETAILS USING UNION

Date :

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 85

Page 86: Full Lab Manua1 - I Sem With Answersl

AIM:

To write a C program to print employee details using unions

ALGORITHM:

Step 1: Start

Step 2: Declare union of employee

Step 3: Read employee details using union variable

Step 4: Print employee details using union variable

Step 5: Stop

PSEUDOCODE:

Set initials union of employees in variables

READ the employee details using union variables

WRITE the employee details using union variables

Stop.

FLOW CHART:

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 86

Page 87: Full Lab Manua1 - I Sem With Answersl

PROGRAM:

#include<stdio.h>

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 87

Start

Declare Structure with variable

Read employee details using Structure

Print employee details using structure variable

Stop

Page 88: Full Lab Manua1 - I Sem With Answersl

#include<conio.h>

union

{

Char name[25];

int idno

float salary

}desc;

void main()

{

Strcpy(desc.name,”vinod”);

clrscr();

printf(“Employee details\n”);

printf(“The name is%s\n”,desc.name);

printf(“The idnois %s\n”,desc.idno);

printf(“The salary is %6.2f\n”,desc.salary);

desc.idno=10;

printf(“Employee details\n”);

printf(“The name is %s\n”,desc.name);

printf(“The idno is %d\n”,desc.idno);

printf(“The salary is %6.2f\n”,desc.salary);

desc.idno=6500.00;

printf(“Employee details\n”);

printf(“The name is %s\n”,desc.name);

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 88

Page 89: Full Lab Manua1 - I Sem With Answersl

printf(“The idno is %d\n”,desc.idno);

printf(“The salary is %6.2f\n”,desc.salary);getch();

}

OUTPUT:

Employee details

The name is vinod

The idno is 26998

The salary id 73784926787784641000000000000.00

RESULT:

Thus the program to print employee details has been using union has been constructed and executed successfully.

PERI Institute of Technology, Mannivakkam, Chennai-48 Page 89