50
Ex.No.1 Document creation and Text Manipulation with scientific notation Aim:- To create a word document and perform text manipulation with scientific notation. I. open a new document and perform the following task (1) Justify the text (2) Make some of the text as bold type (3) Correct the spelling (4) Underline and make italic style for some word (5) Save the documents with a suitable name Procedure (1) Open a new document using file -> new option and type the text (2) For justification select the entire text in the document. Then press Ctrl + J or select the justify button on the formatting tool bar. (3) For Bold face of the words, select the word then press Ctrl + B or select bold button on the formatting tool bar. (4) For spelling correction select the word you want to correct then right click. (5) Click on spelling and grammar button on the standard tool bar. (6) Select the text which you want to make italic style. Then press Ctrl + I or italic button on the formatting tool bar. 1

FOCP Lab Manual Printout[1]

Embed Size (px)

Citation preview

Page 1: FOCP Lab Manual Printout[1]

Ex.No.1Document creation and Text Manipulation with scientific notation

Aim:-

To create a word document and perform text manipulation with scientific notation.

I. open a new document and perform the following task

(1) Justify the text(2) Make some of the text as bold type(3) Correct the spelling(4) Underline and make italic style for some word(5) Save the documents with a suitable name

Procedure

(1) Open a new document using file -> new option and type the text

(2) For justification select the entire text in the document. Then press Ctrl + J or select the justify button on the formatting tool bar.

(3) For Bold face of the words, select the word then press Ctrl + B or select bold button on the formatting tool bar.

(4) For spelling correction select the word you want to correct then right click.

(5) Click on spelling and grammar button on the standard tool bar.(6) Select the text which you want to make italic style. Then press Ctrl + I or italic

button on the formatting tool bar.

(7) For saving the document press Ctrl + S. or Click on save button on the standard tool bar,

(8) Or select the save option from the file menu.

II. How can you do the following alignment features?

Easwari Engineering College (Left Align) Department Of It (Right Align) Ramapuram, Chennai- 89(Center Align) Justify the following paragraph.

Today, the SRM GROUP, with its more than 17 Educational Institutions, in different locations in the Country, is highly ranked amongst the leading Groups of Educational

1

Page 2: FOCP Lab Manual Printout[1]

Institutions. A major thrust is placed for enhancing excellence through a large variety of structured Academic Programs, designed with Topics of relevance, as per UGC Norms; These are included in the Curricula of the SRM Deemed University; these cover Under-Graduate, Post-Graduate Courses and Ph.D. Programs in various Disciplines, such as, Engineering and Technology, Medicine, Dental Science and Surgery, Life Sciences, Management, Hospitality and Hotel Management, Paramedical, Nursing and Arts and Science

Procedure

1) Select the text for alignment 2) For left alignment, press Ctrl + L or press align left button on the formatting tool bar.3) For Center alignment, press Ctrl+E or press align center button on the formatting

tool bar.4) For right alignment, press Ctrl + R or press align right button on the formatting tool

bar.5) For Justification, press Ctrl+J or press Justify button on the formatting tool bar.

III. Insert the symbols given below

☼ -> Sun♫ -> Music™ -> Trade Mark√ -> Tick Mark$ -> Dollar

Procedure

(1) For inserting the symbols

(2) Type the text then put the cursor where you want to add the symbols

(3) Choose the symbols option from insert menu.

IV Change the different types of font types and sizes as given below:

Easwari Engineering College

Easwari Engineering College

Easwari Engineering College

Easwari Engineering CollegeProcedure

2

Page 3: FOCP Lab Manual Printout[1]

(1) Select the text you want to change for font types and sizes.(2) Then Choose font option from the format menu (3) Choose the required forn type from the font drop down list box and the required

size from the size list box on the font dialog box .(4) Then click on Ok.

(V) Try out the following equations in your document

Ca (HCO3)2 CaCo3 + CO2 + H2O

(A + B) 2 = A2 + B2 + 2 A B

( VI ) Try the following equations

Pr

Procedure (1) Click on insert object (2) Choose Microsoft Equation using Equation Editor, Click on Ok (3) Now the Microsoft equation tool bar appears,(4) Using this tool bar , we can type any equations in this document.

Result: Word document document has been created and text manipulations have been performed with scientific notations.

Exercises

1. Add an Animation to the text in the document2. Design a visiting card for a managing director of a company as per the following

specificationsa. The size of the visiting card- 3 ½” X 2 2 ½ “

3. Name of the Company with large font , phone number, email –address and website.

4. Prepare an advertisement for Easwari engineering College5. Create two pages of your curriculum vitae

Ex. No:2

3

Page 4: FOCP Lab Manual Printout[1]

II Table Creation, Table Formatting and ConversionAim: To perform table creation ,table formatting and conversions in MS word

1.Create a Table with the following contentsTitle of the Book AuthorComputer Programming”, Pearson Education (India) (2008

Ashok.N.Kamthane

A Structured Programming Approach Using C”, II Edition, Brooks-Cole Thomson Learning Publications, (2007).

Behrouz A.Forouzan and Richard.F.Gilberg,

Procedure

(1) Choose Table from insert menu(2) It shows the insert table dialog box (3) Then choose the required number of columns and rows(4) Then click ok to add Table in your document(5) Press Tab key to move the cursor from one cell to another

Create the Table with the following columns and display the results in the separate cells for the following

1. Employee Name, Basic Pay, DA ,HRA ,Total Salary2. Sort all Employees in ascending order with the name as the key3. Calculate total Salary of all Employees 4. Calculate Grand Total Salary of all Employees.5. Find maximum and minimum Salary of Employee

Select Table menu bar, then choose insert option Set number of columns to five and number of rows to four and click okNow the Table is inserted in the document with five rows and four columns.Enter the text in the column by pressing tab key leaving total salary blank.

Go to Table menu -> Select Sort , It shows the sort dialog box In the Sort by option select Employee name from the drop down list and select ascending option and click ok.

Place the cursor in the total salary of second row.Click Table ->Formula.It displays the formula dialog box with a formula= SUM (left)Click ok. Now the total salary for the first Employee is displayed at the total salary column. In the same way find the total salary of remaining rows

4

Page 5: FOCP Lab Manual Printout[1]

To find the grand salary, choose, in the formula dialog box Type=SUM(above), No the grand salary is displayed

To find the max and min. salary selectType=MIN(above),Now the minimum salary is displayedType=MAX(above).Now the maximum salary is displayed

Describe the steps to split a Cell and merge two cells in a Table Write the steps to split a single Table to dual Table

Procedure:

(1) Select a cell in a table by clicking on it(2) Select a split cell option from the table menu, the split cell dialogue box appears.(3) Enter your choice to split cells and click Ok

Steps for merging:(1) Select the merge cell option from the table menu.(2) Click leftmost button and the selected cell will become one cell.

Converting a table to Text and text to table:

Converting a table to Text

Select a table in a document(1) Choose the convert table to text option from the table menu.(2) Now it shows the convert table to text dialogue box .(3) Choose the separator of the text. Then click Ok.(4) Now the table information is converted into text in a document.

Converting a text to table

(1) Choose the convert text to table option from the table menu.(2) Now it shows the convert text to table dialogue box .(3) Choose the table size and separator text option . Then click Ok.(4) Now the text information is converted into table.

Result: Table creation, table formatting and conversions have been performed in MS word

5

Page 6: FOCP Lab Manual Printout[1]

Ex. No.3

Mail merge and Letter preparation.

Aim: To prepare a letter using mail merge concept

MAIL MERGE

Mail merge is powerful feature in MS Word that helps you to create form letters, mailing labels, envelopes, or catalogues. With mail merge you can get rid of the usual practice of cutting and pasting labels in every copy of the letter.

The body of the letter is typed and saved in as a file named main document. The addresses are typed and stored in another file called data source. By doing a mail merge you are linking the main document with the data source. Another advantage of using mail merge is that the next time you need to send a letter to the same set of recipients, you can use the same data source file.

Getting Started with Mail Merge

Step 1: Click Start All Programs Microsoft Word.

Step 2: Click Tools Letters and MailingsMail Merge

Select document type Letters

Step 3: Next: Starting documentSelect ‘Use the current document’

Step 4: Next: Select recipients-select ‘Type a new list’

Step 5: Click Create link

6

Page 7: FOCP Lab Manual Printout[1]

Step 6: Type the list of addresses(at least 3) and click to close. (Close will automatically save –Give a name of the file).

7

Page 8: FOCP Lab Manual Printout[1]

Step 7: Next: Write your letter

Dr. K.ABDUL GHANI, B.E, M.E, Ph.D., Date: 31.07.2009PRINCIPAL

ToThe Administrative OfficerMadras Atomic Power StationKalpakkam – 603 102.

Dear Sir,

Sub: Industrial Visit - permission – reg.

Easwari Engineering College has been imparting Technical and Management education for more than 15 years. We offer courses in Engineering and Management for under graduate and post graduate to produce quality Engineers to the Industries.

As per the curriculum the students of Information Technology branch have to be exposed to the latest practices in Industries. IGCAR Kalpakam is one of the reputed Atomic Power Stations in India which has to be familiarized with the students. Hence it is requested to permit the students who are studying in our college in IT branch to visit the IGCAR on the proposed dates noted below.

S.No Year / Sem No of Students No of Staff Proposed Dates1 IV / VII 120 4 15.09.2009 –

30.09.20092 III / V 120 4 10.08.2009 –

17.08.20093 II / III 120 4 18.08.2009 –

26.08.2009

We shall be very grateful if you kindly permit them to visit your plant and oblique.

Thanking you.Yours faithfully,

PrincipalContact Person:K.Parimala Kanaga DevanAssistant Profeesor / ITEaswari Engineering College

8

Page 9: FOCP Lab Manual Printout[1]

Mobile: 9841726794.E_Mail: [email protected]

Step 8: Click more items… linkSelect the address fields and press Insert button-This will bring the corresponding fields in the main document.

Step 9: Next: Preview your letters link.

Step 11: Next: Complete the merge

Step 12: Edit individual letters… link In the dialogue box that appears, select All and click OK to see the

merged letter.

9

Page 10: FOCP Lab Manual Printout[1]

Result: A Letter has been prepared using mail merge concept.

Ex.No 4

10

Page 11: FOCP Lab Manual Printout[1]

Drawing flow chart

Aim: To draw a flow chart for a given problem using MS wordProcedure:1. Choose Flowchart option in the Auto shapes menu of the Drawing Tool bar2. Choose the appropriate flowchart symbol, then drag the symbol in the document.3. Type the text in the symbol, by right click, then choose Add Text.4. Using the Arrow button in the drawing tool bar draw lines connecting to the different flowchart symbols.5. Select all the flowchart symbols and lines in the document using the objects button, then right choose grouping, then click on group.6. Now all the Flowchart symbols are grouped into one.

Flow Chart to compute sum of ‘N’ Numbers

Result:Thus the flowchart has been drawn for computing sum of n numbers using MS word

Start

Stop

Read N

Print Sum

If N>0

Sum=N*(N+1) / 2Yes

No

11

Page 12: FOCP Lab Manual Printout[1]

MS EXCEL CASE STUDY

MS Excel is spreadsheet software used to create and manage data and also for analyzing the data for information. The usage of this software is similar to MS Word, and is simple menu-driven software.

Excel spreadsheet consists of a grid of rows and columns. The intersection of a row and a column is called a cell. The rows are numbered 1, 2, 3 ….and so on, and columns are labelled alphabetically A, B, C… and so on. Each spreadsheet contains 16384 rows and 256 columns that make 4,194,304 cells. Each cell can store a piece of text, number or formula in it.

Getting Stared with Excel:

Click Start All Programs Microsoft Excel to start.

12

Page 13: FOCP Lab Manual Printout[1]

Parts of an Excel Spreadsheet :Just like MS Word we have the Title bar, Menu Bar, Tool bar, Formatting Tool bar, Scroll bar etc. In addition to these, there are Formula bar and Cells to store and work with data.

Question:The ABC Company shows the sales of different products for 5 years.Create BAR Graph, 3D, Pie and LINE.

Aim:TO Create a BAR Graph,3D,Pie and Line Charts for Sales Report of given

Company

Procedure:

1. Enter the data in the worksheet as shown in Question.2. Choose Chart option from the Insert menu, or choose the Chart Wizard

button from the standard tool bar.(Note:-It shows the Chart Wizard Step 1 of 4 Chart Type dialog box.).

13

EX.NO:5Chart - Line, XY, Bar and Pie

DATE:

Page 14: FOCP Lab Manual Printout[1]

3. Choose appropriate Chart type from the Chart type list box then click next.(Note:-It shows the Chart Wizard Step 2 of 4 Chart source data dialog box.).

4. Select data range and series Values from work sheet then click next. .(Note:-It shows the Chart Wizard Step 3 of 4 Chart Option dialog box.).

5. Give Chart title, X- Axis, Y-Axis Titles etc, then click next. .(Note:-It shows the Chart Wizard Step 4 of 4 Chart Location dialog box.).

6. Select the location in which you want to place the Chart, and then click Finish.

Now the Chart is displayed on your Workbook/Worksheet as shown below any.

BAR GRAPH:

ABC COMPANY SALES

0 500 1000 1500 2000

2005

2006

2007

2008

2009

Year

No.of Products

PRODUCT4PRODUCT3PRODUCT2PRODUCT1

3D GRAPH:

14

Page 15: FOCP Lab Manual Printout[1]

0%

20%

40%

60%

80%

100%

sales %

2005 2006 2007 2008 2009

year

ABC COMPANY SALES

PRODUCT4PRODUCT3

PRODUCT2PRODUCT1

PIE CHART:

ABC COMPANY SALES 2005

PRODUCT1, 1000, 27%

PRODUCT2, 800, 22%

PRODUCT3, 900, 24%

PRODUCT4, 1000, 27%

PRODUCT1PRODUCT2

PRODUCT3PRODUCT4

LINE CHART:

15

Page 16: FOCP Lab Manual Printout[1]

Result:

Thus various Charts have been Created successfully.

16

Page 17: FOCP Lab Manual Printout[1]

Ex.No 6. Formula - formula editor

Date:

Aim:

To create a spread sheet to analyse the marks of the students of a

class

Procedure:

Let us create a spreadsheet of marks of the students of a class and also prepare charts to analyse the marks. Consider a list of 10 students and their test marks. Tabulate the marks and prepare a chart to show the average marks scored by the students in the subjects.

Step 1: Launch MS Excel to create a blank presentation.

Step 2: Click on the first cell and type the title of the table

Step 3: Now select any cell below the title and type the name of the subjects.

Step 4: Enter the marks secured by the students in the cells just below the respective subjects. To edit the content of a cell, click on the cell and press the F2 key.

17

Cells

Formula barar

Page 18: FOCP Lab Manual Printout[1]

Step 5: You can adjust a cell to fit its content by selecting AutoFit. Click Format in the menu bar Column AutoFit Selection.

Step 6: To calculate the average, click and select an empty cell below the marks. Select function from Insert menu.

18

Page 19: FOCP Lab Manual Printout[1]

Step 7: Select AVERAGE from the function.

Step 8: Confirm the ranges of data in the cell i.e. from cell B9:B18 and click OK. The average will be displayed on the cell.

19

Page 20: FOCP Lab Manual Printout[1]

Step 9: To copy the average function for other subjects, simply hold the lower right corner of the cells and drag it using left mouse button. Now the average marks for other subjects will be displayed.

20

Page 21: FOCP Lab Manual Printout[1]

Result:

Thus Student’s Mark Sheet has been creared and analysed successfully.

21

Page 22: FOCP Lab Manual Printout[1]

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

Question:

1. Insert object in the Worksheet.2. Insert a picture in the Worksheet.3. Insert a comment in the Worksheet.4. Insert an Organization chart of a College in the Worksheet.5. Protect a sheet in MS-Excel.6. Protect the Workbooks in MS-Excel.

Aim:

To Insert an Object in the WorkSheet,To Insert a Picture in the WorkSheet,To Insert a comment in the WorkSheet,To Insert an Organization Chart of a College in the Worksheet,To Protect a sheet in MS-Excel and ToProtect the Workbooks in MS-Excel.

Procedure:

1.Insert object in the Worksheet.

a) Choose Object option in the Insert menub) Create new Object in which you want to insert or Select object from Listed set of

Objects already created.c) Click OK.(Note:- It Shows selected object in your worksheet or workbook For

example Calender Control 8.0.)

22

Page 23: FOCP Lab Manual Printout[1]

2.Insert a picture.

a) Choose Picture option from the Insert Menu.b) Then choose From File option.(Note:-Now the Insert Picture dialog box is

shown.)c) Navigate and choose the picture to insert into the worksheet.d) Then click on Insert button.(Note:-Now the selected picture is inserted into the

Worksheet.)

23

Page 24: FOCP Lab Manual Printout[1]

3.Inserting comments in the worksheet.

a) Select the Cell in which comment to be added.b) Choose Comments option in the Insert Menu.(Note:-Now the Comment portion of

the particular cell is edited.)

c) Then type the comments for the cell.d) Click on the outside of the comment.(Note:-Whenever you place the cell pointer

in that cell, the comment is automatically shown.)

4.Organization Chart.

a) Choose Organization Chart option in the Picture option of the Insert Menu. (Now it opens the Microsoft Organization Chart.)b) Type the text in the boxes provided and use appropriate options.

24

Page 25: FOCP Lab Manual Printout[1]

5.Protect a sheet in MS-Excel.

To Protcet the Sheet,a) Click on the cell, which you want to protect.b) Choose Tools->Protection, then choose Protect Sheet(Note:- It shows the

Protect Sheet dialog box asking the Password to protect sheet.)c) Type the password click and OK. Then it asks for confirmation password box.

Type the same password again and then click OK.(Note:- Now the sheet is under protection.)

d) If you click on any cell to type, then the following message box appears by specifying the sheet under protection.

25

Page 26: FOCP Lab Manual Printout[1]

To remove protection , choose Tools->Protection->Unprotect Sheet, then type the password to unprotect.( Note: - Now the sheet can be unprotected.)

6..Protecting the Workbook.To protect the Sheet

a) Open the Workbook to protect.b) Choose Tools->Protection, then choose Protect Workbook, it shows the Protect

Workbook dialog box asking the password to protect sheet.c) Type the password and click OK. Then it asks for confirmation password box. d) Type the same password again and then click OK.

(Note:-Now the sheet is under protection.)e) If you click on any cell to type, then the following message box appears by

specifying the sheet under protection.To remove protection choose Tools->Protection->Unprotect Sheet, then type the password to unprotect. (Note:- Now the sheet can be unprotected.)

Result:

Thus Various Insertion and Protection procedures have been implemented successfully.

26

Page 27: FOCP Lab Manual Printout[1]

Ex.NO 8. Sorting and Import / Export features.

Question:

I. Enter the following data into the worksheet using the Data->Form Command.

Sort the data by “Salary” within the department using “Sort” Command.Calculate total salary of each department using Auto Filter.

Procedure:

1. Enter the Name, Department, Salary in different columns.2. Click Data->Form option,it shows the form as shown below.

27

Page 28: FOCP Lab Manual Printout[1]

3. Click New button in the Form to add the rows to the list.4. After adding the rows, place the cursor in the list in the worksheet.5. Click Data-> Sort,it shows the Sort diaiog box,as shown below.

6. In the Sort by drop list Dept, click OK.7. Again in Sort, click Salary from then By drop down list.8. The rows are sorted now, depending on the DEPT and SALARY.9. Click Data->Filter->Autofilter,it shows an arrow at each field.

28

Page 29: FOCP Lab Manual Printout[1]

10.On the Dept click the icon select CSE.(Note:- The list of rows which belongs to CSE is displayed.)

11.Place the cursor in A15, find the sum using SUM formula. In the same way find each departments total salary.

29

Page 30: FOCP Lab Manual Printout[1]

II.Import and Export Features:

Question:Import the Data from Specified Table to given Worksheet.

Solution:Steps:

1. Create a Table in which you want to import from outside Window .

2. Open the Worksheet and Select Import External Data from Data Option.3. Select Import Data Option.4. Select the Database file you want to import .5. Specify the location you want to put the Table.6. Click OK(Note:- Table will be shown in your Work Sheet as below.)

Result:-

30

Page 31: FOCP Lab Manual Printout[1]

Exp.No:9

Aim:-

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

Flow Chart

31

is n2 = 0

yes

no

no

no

yes

StopPrint q

Stop

yes

yes

no

Start

Read option

Read n1, n2

is option =1

Print a

Stop

a n1 + n2

p n1 * n2

Print “Division by zero-Error”

Print p

q n1 / n2

is option =2

is option =3

is option =4

yes

StopStop

Print s

s n1 – n2

Stop

no

Page 32: FOCP Lab Manual Printout[1]

// Program:-/* program to simulate a simple calculator */#include <stdio.h>#include <conio.h>

void main( ){

int option, n1, n2, a, s, p, q ;//clrscr ( ) ;printf ("\n\t\t Menu") ;printf ("\n Press 1 for Addition") ;printf ("\n 2 for Subtraction") ;printf ("\n 3 for Multiplication") ;printf ("\n 4 for Division") ;printf ( "\n\n Enter your option : \n") ;scanf ("%d", &option) ;printf ("\n Enter first value : \n") ;scanf ("%d", &n1) ;printf ("\n Enter second value : ") ;scanf ("%d", &n2) ;

switch(option) {case 1 : a = n1 + n2; printf ("\n Addition n1+n2 = %d", a); break; case 2 : s = n1 - n2; printf ("\n Subtraction n1-n2 = %d", s); break;

case 3 : {p = n1 * n2; printf("\n Multiplication n1*n2 = %d", p);} break;

case 4 : if(n2 == 0) { printf ("\n Division by zero, program terminated"); q = n1/n2; printf ("\n Division n1/n2 = %d" , q);} break;

default : printf ("\n Wrong operation selection, stop "); break;}

getch( );

}

Result:-

32

Page 33: FOCP Lab Manual Printout[1]

Exp.No:10

Aim:-

To write a program for electricity bill preparation for the following datas:

The Electricity Board charges its domestic consumers as follows:Consumption in units Rate charged per unit0 – 200 Re.0.50 201 – 400 Rs.100 plus Re.0.65 per unit excess of 200401 – 600 Rs.250 plus Re.0.80 per unit excess of 400Above 600 Rs.425 plus Rs.1.25 per unit excess of 600Print the amount to be paid by the consumer.

Pseudo code:-

1. Get a value of total units consumed for units2. If units <=200 then3. Set the value of amt to 0.5 * units4. Else if units <=400 then5. Set the amt to 100 + 0.65 * (units – 200)6. Else if units <=600 then7. Set the amt to 25 + 1.25 * (units – 600)8. END IF 9. END IF10. END IF11. Return the value of amt

// Program:-

/* Program to calculate and print electricity bill */#include <stdio.h>#include <conio.h>main(){

unsigned int units;float amt;clrscr();printf (“\n Enter total units consumed : “);scanf (“%d”,&units);if (units <= 200) amt = 0.5*units;else if(units <= 400)amt = 100 + 0.65*(units - 200);else if (units <= 600)amt = 230 + 0.8*(units - 400);else if (units <= 600)amt = 25 + 1.25*(units – 600);printf (“\n Amount to be paid Rs.%6.2f\n”,amt);getch();

}

Result:-

33

Page 34: FOCP Lab Manual Printout[1]

Exp.No:11

Aim:-

To write a program to compute the following sine series

//Algorithm:-

Step 1: Initialize the variablesX0.52, numerator x, denominator1.0 ,sign 1.0 ,sin 0

Step 2: initialize terms10Step 3: for i in 1 to 10 then compute sin sin + numerator / denominator * sign

Numeratornumerator * x * x Denominatordenominator * I * (i*2 +1) , sign=sign * 1

Step 4: Display sin

//Program:-

#include<conio.h> #include<math.h>

void main() { double x=0.52;double numerator = x; double denominator = 1.0; double sign = 1.0; double sin = 0; int i;// terms below define the number of terms you want int terms = 10; for (i = 1 ; i <= 10 ; i++ ) { sin += numerator / denominator * sign; numerator *= x * x; denominator *= i*2 * (i*2+1); sign *= -1; } printf("Result=%f",sin); }

Result:-

34

Page 35: FOCP Lab Manual Printout[1]

Exp.No:12

Aim:-

To write a C program to solve the following cosine series:

s = 1 -

//Program:-

#include<stdio.h> #include<conio.h> #include<math.h> main() { int i,n,x; double t,s; //clrscr(); printf("enter the value of k,n \n"); scanf("%d%d",&x,&n); t=1; s=1; for(i=1;i<=n-1;i++) { t=(-1)*((pow(x,2)*t*i))/((2*i)*((2*i-1)*i)); s=s+t; printf("s=%6.2f & t=%6.2f\n",s,t); } printf("\n sum of the cos series=%5.2f\n",s); return(0); }

Result:

35

Page 36: FOCP Lab Manual Printout[1]

Exp.No:13

Aim:-

To write a C program to multiply matrix A of order m x n with matrix B of order n x l.

// Program:-

/* Program for matrix multiplication *\#include <stdio.h>#include <conio.h>#include <math.h>main( ){

int a[10] [10], b[10] [10], c[10] [10], m, n, i, j, k, l; clrscr( ); printf (“\n Enter order of matrix A : “);scanf (“%d %d”,&m,&n);

/* Loop to read values of matrix A *\printf (“ Enter matrix A \n”);for (i = 0; i < m; i++); for (j = 0; j<n; j++) scanf (“%d”, &a[i] [j]);printf (“\n Enter order of matrix B : “);scanf (“%d %d”, &n,&l);

/*Loop to read values of matrix B */printf (“ Enter matrix B \n”);for (i= 0; i < n; i++) for (j = 0; j< 1; j++) scanf (“%d”, &b[i] [j]);

/* Loop to multiply two matrices */for (i = 0; i< m; i++)

for (j = 0; j<1; j++) { c [i] [j] = 0; for (k =0; k<n; k++)

c[i] [j] = c[i] [j] + a[i] [k]*b[k][j]; }/* Loop to print the resultant matrix */

printf (“\n Resultant matrix C is \n”);for (i =0; i<m; i++){

for (j = 0; j<1; j++) printf (“%6d”, c[i] [j] ); printf (“\n”); }

getch( );}

Result:

36

Page 37: FOCP Lab Manual Printout[1]

Exp.No:14

Aim:-

To write a C program to concatenate two strings without using library functions.

//Program:-

/* Program to concatenate two strings */#include <stdio.h>#include <conio.h>#include <string.h>main( ){

char st1[10],st2[10],st[20];int i, j;clrscr( );printf (“\n Enter first string : ”);scanf (“%s”, st1);printf (“\n Enter second string : “);scanf (“%s”, st2);

/* Loop to copythe first string to resultant string */i = 0; j = 0;while (st1[i] != ‘\ 0’){

st [j] =st1 [i]; i++; j++;}

/* Add a white space before joining the second string */st[j] = ‘ ‘;j++;

/* Loop to join the second string */i = 0;while(st2 [i] != ‘\ 0’){ st [j] = st2 [i]; i++; j++;}st [j] = ‘\ 0’;printf (“\n Resultant string is %s “, st);getch( );

}

Result:

37

Page 38: FOCP Lab Manual Printout[1]

Exp.No:15

Aim:-

To Write a C program to read a string, and find its length, and also copy it to another string variable without using library functions.

// Program:-

#include <stdio.h>#include <conio.h>#include <string.h>main( ){ char st1[10], st2[10];

int l, i, j;clrscr( );printf (“\n Enter the string : “);scanf (“%s”, st1);

/* Loop to find length of string */l = 0;i = 0;while (st1[i] != ‘\ 0’){ l ++; i++;}printf (“\n Length of string : %d”, l);

/* Loop to copy the string */i = 0;j = 0;while (st1 [i] != ‘\ 0’;{ st2 [j] = st1 [i];i ++;j ++;}st2 [j] = ‘ \ 0’;printf (“\n The copied string : %s “, st2);getch( );

}

Result:

38

Page 39: FOCP Lab Manual Printout[1]

Exp.No:16

Aim:-

To write a program to arrange names in alphabetical order.

// Program:-

#include <stdio.h>#include <conio.h>#include <string.h>main(){

char names[50] [20], temp[20];int n,i,j;printf(“\n How many names ? “);scanf(“%d”, &n);printf (“\n Enter the %d names one by one \n”);for (i = 0; i < n; i++) scanf (“%s”,names [i]);

/* Loop to arrange names in alphabetical order */for (i = 0; i < n-1; i ++) for ( j = i +1; j < n; j++) if (strcpy(names [ i ], names [ j ]) > 0

{ strcpy ( tmp, names [ i ] ) ;

strcpy ( names [ i ], names [ j ] ) ; strcpy (names [ j ], tmp) ;

}/* Loop to print the alphabetical list of names */ printf (“\n Names in alphabetical order “); for ( i = 0; i < n; i++) printf( (“\n %s”, names [ i ] ); getch( );}

Result:

39

Page 40: FOCP Lab Manual Printout[1]

Exp.No:17

Aim: -

To write a C program to find the arithmetic mean of n values using functionProgram

// Program:-

#include <stdio.h>#include <conio.h>#include <math.h>main( )

{ float x[10], xbar;int n, i;float amean(float x[], int, n);float variance(float x[], int n, float xb);printf(“\n How many values? : “);scanf(“%d”, &n);/* Loop to read all values */printf(“\n Enter all values \n”);for (i = 0; I < n; i ++)scanf(“%f”, &x[i] );/* Call function to print arithmetic mean */xbar = amean(x, n);printf(“\n Arithmetic mean = %6.3f ”, xbar);printf(“\n Variance = %6.3f “ , variance(x, n, xbar);printf(“\n Standard deviation = %6.3f “ , sqrt(variance (x, n, xbar) ) );getch( );

}

/* Function to find arithmetic mean */float amean ( float x[], int n);{ int i;

float s = 0;for( i = 0; i< n; i ++ s += x[i];return (s/n);

}

/* Function to find variance */float variance(float x[], int n, float xbar);{ int i;

float vs = 0;for(i = 0; i < n; i ++) vs += (x[i] – xbar) *(x[i]-xbar);return(vs/n);

}

40

Page 41: FOCP Lab Manual Printout[1]

Result:Exp.No:18

Aim:-

To print the mark sheet of n students using structures

// Program:-

#include <stdio.h>#include <conio.h>main( ){/* declaring a structure and an array */

struct student; { int rno; char sname[20] ; int tot ; } std[50] ; int i n, flag, temp; char ch = ‘Y’ ;

printf (“\n How many students ? “) ; scanf ( “%d”, &n) ;/* loop to read details of n students */ for(i = 0; i < n; i ++) ; { printf (“\n Roll number? “) ; scanf (“%d”, &std [i] . rno) ; printf (“ Name ? “) ;

scanf (“%s”, &std [i] . sname) ; printf (“ Total marks? “) ; scanf (“%d”, &std [i] . tot); }/*display marks of a student */ while (ch = = ‘y’ || ch = = ‘Y’) { printf (“ Enter student roll number to display marks : “) ; scanf (“%d”, &temp) ; flag = 0 ;/* loop to search and display marks */ for (i = 0; i < n && flag = = 0; i++) if (std [i] . rno = = temp) { printf (“\n Marks obtained by %d %s “, std [i] . rno, std [i] . sname) ; printf (“\n Total : %d”, std [i] . tot) ; flag = 1 ; } if (flag == 0) printf (“\n %d is not present in the list”, temp) ; printf (“\n press y - to continue”) ; printf (“\n any other key to stop.”) ; ch = getch( ) ;

}}

Result:

41

Page 42: FOCP Lab Manual Printout[1]

Exp.No:19

Aim:-

To print the Employee Details using Union

// Program:-

#include <stdio.h>#include <string.h>

union Employee{

int Empid;char Name[20];float Salary;

};

void main(){

union Employee e1,e2,e3;

e1.Empid=1234;strcpy(e2.Name,"Mr.M.Vivekanandan");e3.Salary=12000.50;

printf("\n***************************************************************************\n");printf("\nThe Employee Details are.......\n");printf("\n***************************************************************************\n");printf("\nEmpid=%d\nEmp Name=%s\nSalary=%f\n",e1.Empid,e2.Name,e3.Salary);

printf("\nsizeof Empid=%d\nsize\of Name=%d\nsizeof Salary=%d\n",sizeof(e1.Empid),sizeof(e2.Name ),sizeof(e3.Salary ));

}

Result:-

42