Top Banner
COMPUTER PRACTICES LABORATORY I DOCUMENT CREATION, TEXT MANIPULATION WITH SCIENTIFIC NOTATIONS Aim: To open a new open office document and perform the following operations in it. 1. Text Alignment 2. Change line spacing to 1.5 3. Place a box to the entire text 4. Add the bullets and numbering 5. Change type of font types and sizes 6. Insert the symbols Algorithm: 1. To open OpenOffice writer use , Start > All Programs > OpenOffice.org 3.2 > OpenOffice.org Writer. 2. On the Menu Bar click, File > New > Text Document now a text document appears on your screen with name at the top of the screen. 3. Enter some text in it and select the text and make it as justified text by clicking Align Left icon in the tool bar or ctrl+L. 4. Enter some text in it and select the text and make it as justified text by clicking Align Right icon in the tool bar or ctrl+R. Computer Science & Engineering Page 1
66
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: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

DOCUMENT CREATION, TEXT MANIPULATION WITH

SCIENTIFIC NOTATIONS

Aim:

To open a new open office document and perform the following operations in it.

1. Text Alignment

2. Change line spacing to 1.5

3. Place a box to the entire text

4. Add the bullets and numbering

5. Change type of font types and sizes

6. Insert the symbols

Algorithm:

1. To open OpenOffice writer use , Start > All Programs > OpenOffice.org 3.2 > OpenOffice.org Writer.

2. On the Menu Bar click, File > New > Text Document now a text document appears on your screen with name

at the top of the screen.

3. Enter some text in it and select the text and make it as justified text by clicking

Align Left icon in the tool bar or ctrl+L.

4. Enter some text in it and select the text and make it as justified text by clicking Align Right icon in the tool bar or ctrl+R.

5. Enter some text in it and select the text and make it as justified text by clicking Align Center icon in the tool bar or ctrl+E.

6. Enter some text in it and select the text and make it as justified text by clicking Align Justification icon in the tool bar or ctrl+J.

7. Make a line spacing between the lines as 1.2 using Format > Paragraph > Indent & Spacing then select line spacing as fixed and change it to 1.5

Computer Science & Engineering Page 1

Page 2: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

8. To insert a box to a text select the box from drawing tool by , ToolBar -> Drawing

9. Makes the text as bullets and numbering by Format > Bullets and Numbering.

10. Change the style and size of the text by using the options in the tool bar or use Format > Character.

11. Insert special characters by Insert > Special Characters.

Output:

1. Text Alignment

LEFT

A computer is a programmable machine that receives input, stores and manipulates data/information, and provides output in a useful format.

RIGHT

Input: Information and programs are entered into the computer through Input devices such as the keyboard, disks, or through other computers via network connections or modems

connected to the Internet. The input device also retrieves information off disks.

CENTER

Output: Output Devices displays information on the screen (monitor) or the printer and sends information to other computers. They also display messages about what errors may

have occurred and brings up message or dialog box asking for more information to be input. The output device also saves information on the disk for future use.

JUSTIFY

Processing: The CPU or central processing unit is sometimes called the Control Unit and directs the operation of the input and output devices. The Coprocessor or the Arithmetic-Logic Unit does arithmetic and comparisons. The memory or RAM temporarily stores information (files and programs) while you are using or working on them. The BIOS or basic input/output system controls the dialogue between the various devices.

2. Change line spacing to 1.5

Line Spacing - 1.0

The CPU or central processing unit is sometimes called the Control Unit and directs the operation of the input and output devices. The Coprocessor or the Arithmetic-Logic Unit does arithmetic and comparisons. The memory or RAM temporarily stores information

Computer Science & Engineering Page 2

Page 3: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

(files and programs) while you are using or working on them. The BIOS or basic input/output system controls the dialogue between the various devices.

Line Spacing – 1.5

The CPU or central processing unit is sometimes called the Control Unit and directs the

operation of the input and output devices. The Coprocessor or the Arithmetic-Logic Unit

does arithmetic and comparisons. The memory or RAM temporarily stores information

(files and programs) while you are using or working on them. The BIOS or basic

input/output system controls the dialogue between the various devices.

3. Placing a box to the entire text

4. Adding bullets and numbering

Bullets Keyboard Mouse

Numbering1. Printer2. Monitor

5. Changing type of font types and sizes

Times New Roman 8

Verdana 10

Book Antiqua 12

Arial black 14

6. Inserting the symbols

Pie - ∏

Summation - ∑

Computer Science & Engineering Page 3

UNITED INSTITUTE OF TECHNOLOGY

Page 4: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

7. Superscript and Subscript

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

Ca(HCO3)2 -> CaCO3 + Co2 + H2O

8. Inserting Equations

Result:

Thus the required operations in the word document have been made and the output has been obtained.

Computer Science & Engineering Page 4

Page 5: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

ADVERTISEMENT

Aim:

To prepare an advertisement to a company with the following specifications

i. Attractive Page Border.

ii. Design the name of company using WordArt.

iii. Use ClipArt

Using of OpenOffice writer.

Algorithm:

1. To open OpenOffice writer use , Start > All Programs > OpenOffice.org 3.2 > OpenOffice.org Writer.

2. On the Menu Bar click, File > New > Text Document now a text document appears on your screen with name

at the top of the screen.

3. Save file use File > Save As> give valid name and click Save.

4. Select the Page Border use Format > Page > Borders then select your style of Page Border.

5. Design the company name use View > Toolbars > FontWork Enable FontWork Option and Design Company Name.

6. Insert ClipArt use Insert > Pictures select the picture and insert.

Computer Science & Engineering Page 5

Page 6: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:

Result:

Thus the above Advertisement to a company has been designed and the output has been obtained.

Computer Science & Engineering Page 6

Page 7: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

VISITING CARD

Aim:

To design a Visiting Card for a company following specification

i. Size of the Visiting Card 4” X 3”.

ii. Name of the company with a WortArt.

Using of OpenOffice writer.

Algorithm:

1. To open OpenOffice writer use , Start > All Programs > OpenOffice.org 3.2 > OpenOffice.org Writer.

2. On the Menu Bar click, File > New > Text Document now a text document appears on your screen with name

at the top of the screen.

3. Save file use File > Save As> give valid name and click Save.

4. Size of Visiting Card use Format > Page > Page > then change the Width and height

5. Design the company name use View > Toolbars > FontWork Enable FontWork Option and Design Company Name

OUTPUT:

Result:

Thus the above Visiting Card to a company has been designed and the output has been obtained.

Computer Science & Engineering Page 7

Page 8: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

LETTER HEAD

Aim:

To Create a Letter Head for UIT College Using of OpenOffice writer.

Algorithm:

1. To open OpenOffice writer use , Start > All Programs > OpenOffice.org 3.2 > OpenOffice.org Writer.

2. On the Menu Bar click, File > New > Text Document now a text document appears on your screen with name

at the top of the screen.

3. Save file use File > Save As> give valid name and click Save.

4. Size of Visiting Card use Format > Page > Header > then Enable Header On option

5. Size of Visiting Card use Format > Page > Footer > then Enable Footder On option

Computer Science & Engineering Page 8

Page 9: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

OUTPUT:

Result:

Thus the above Letter Head for UIT College has been designed and the output has been obtained.

Computer Science & Engineering Page 9

Page 10: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

SCIENTIFIC NOTATION AND FORMULA

Aim:

To create Scientific Notation and Formula using OpenOffice.org.

Algorithm:

1. To open OpenOffice writer use , Start > All Programs > OpenOffice.org 3.2 > OpenOffice.org Writer.

2. On the Menu Bar click, File > New > Text Document now a text document appears on your screen with name

at the top of the screen.

3. Save file use File > Save As> give valid name and click Save.

4. Scientific Notation use Format > Character > Position then Enable Superscript and Subscript options

5. Insert Formula use Insert > Object > formula then Enter your Formula

Output:

Scientific Notation:

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

Ca(HCO3)2 -> CaCO3 + Co2 + H2O

Formula:

Result:

Thus the above Scientific Notation and Formula created and the output has been obtained.

Computer Science & Engineering Page 10

Page 11: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

TABLE CREATION, TABLE FORMATTING AND CONVERSION

Aim:

To perform Table Creation, Formatting and Conversion using OpenOffice.org .

Algorithm:

1. To open Open Office writer use , Start > All Programs > OpenOffice.org 3.2 > OpenOffice.org Writer.

2. On the Menu Bar click, File > New > Text Document now a text document

appears on your screen with name at the top of the screen.

3. To insert a new table, position the cursor where you want the table to appear, then use any of the following methods to open the Insert Table dialog box:

From the main menu, select Table > Insert > Table.

Press Ctrl+F12.

From the Standard toolbar, click the Table icon

4. Under Size, change the no of columns and rows based on the document.

5. In the Options space,

Heading defines the first row(s) in the table as headings

Repeat heading repeats the heading row(s) of the table at the top of subsequent pages if the table spans more than one page.

Don’t split table prevents the table from spanning more than one page.

Border surrounds each cell of the table with a border. This border can be modified or deleted later.

The AutoFormat button opens a dialog from where it is possible to select one of the many predefined table layouts.

6. Click OK to create the table of your choice.

7. To insert rows in the table later,

Use tab key to add rows in the last column.

Computer Science & Engineering Page 11

Page 12: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Click Table > Insert > Rows or click the Insert Rows icon .

Right click select Row > insert

8. To insert columns in the table later,

Click the second column, Table > Insert > Columns or click the Insert

Column icon.

Right click select Column > insert.

9. To delete rows and columns,

Click in one of the empty rows you just added, click Table > Delete > Rows

or click the Delete Row icon(The row is deleted.).

Click in the empty column you just added, click Table > Delete > Columns

or click the Delete Column icon on the Table Toolbar(The middle column is deleted.).

10. For Table Conversion,

Select the text and click Table > Convert > Text to Table > Paragraph. Under Separate text at, select Tabs or Semicolon or Other to determine what will be used to divide the data into different cells.

To convert table into text, click in the table then click Table > Convert > Table to Text > Paragraph.

11. To Delete Table,

Click the table you want to delete.

Click Table > Delete > Table.

Computer Science & Engineering Page 12

Page 13: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:

Table To Text Conversion

Roll_No;Name

101;Senthil kumar K

102;Raj Kumar P

103;Sathish B

Text To Table Conversion

Roll_No

Name

101 Senthil kumar K

102 Raj Kumar P

103 Sathish B

Result:

Thus the operations on the table have been performed and the required output has been obtained using OpenOffice.org

Computer Science & Engineering Page 13

Page 14: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

MAIL MERGE AND LETTER PREPARATION

Aim:

To perform mail merge and letter preparation using OpenOffice.org.

Algorithm:

1. To open Open Office writer use , Start > All Programs > OpenOffice.org 3.2 >

OpenOffice.org Writer.

2. On the Menu Bar click, File > New > Text Document.

3. Click Tools > Mail Merge Wizard, the Mail Merge Wizard window will appear.

4. Under select starting document select create a new document then click next.

5. Select document type as letter, then click next.

6. In the address list click OK then click next.

7. In the create salutation space check this document should contain a salutation then

click next.

8. In the adjust layout space, we can adjust the alignment and salutation position and

click next.

9. Edit document space, click edit document if needed click next.

10. Personalize document, we can edit individual document.

11. Save the document by clicking save starting document button and enter the

document name, click OK.

12. Click Finish.

Computer Science & Engineering Page 14

Page 15: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:From

M.Anantha Krishnan

BE CSE A I YEAR

United Institute of Technology

Coimbatore-20.

To

Mr.N.K.Madhavan

No.15,IT Quarters,

Coimbatore - 641044

India

Respected Sir/Madam,

SUBJECT: Regarding a symposium on Internet.

I take great privilege to welcome you for the symposium which is to

be conducted in our college. The symposium is about the various advancements in

internet.Mr.Bill Gates ,chairman of Microsoft Corporation has accepted to

deliver a guest lecture on 27th of September 2008.The program commences by

10.00 am and ends by 12.30 pm.Kindly grace this occasion with your august

presence.

Thanking you.

Yours Sincerely

M.Ananthakrishnan

Result:

Thus the mail merge operation have been performed and the required output has

been obtained.

DRAWING – FLOW CHART

Computer Science & Engineering Page 15

Page 16: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Aim:

To draw a flow chart for a given problem in the OpenOffice.org.

Algorithm:

1. Open a new open office document.2. Open drawing toolbar by clicking View > Toolbars > Drawing.3. Draw a flow chart for the given problem by using the drawing tool bar.

Output:

Result:Thus the flow chart has been drawn for the greatest of three numbers problem

and the required output has been obtained.

Computer Science & Engineering Page 16

Page 17: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

CHART – LINE, XY, BAR AND PIE

Aim:

To Draw a line, XY, bar and pie chart for a given user data in OpenOffice.org Calc .

Algorithm:

1. Click Start > Programs > OpenOffice.rg > OpenOffice.org calc.

2. Enter the data.

3. Select the data to be manipulated.

4. Click Insert > Chart then select Line to display line chart.

5. Do the above steps for XY, Bar and Pie charts.

Output:

Result:

Thus the required operation is performed and the required output is obtained.

Computer Science & Engineering Page 17

Page 18: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

FORMULA – FORMULA EDITOR

Aim:

To perform the formula editor in OpenOffice.org Calc .

Algorithm:

1. Click Start > Programs > OpenOffice.rg > OpenOffice.org calc.

2. Enter the data.

3. Click View > Formula Bar.

4. Perform the required operations in the formula editor.

5. Display the output.

Output:

S.NO STU NAME PHY CHE MAT COMP ENG TOTAL PERCENTAGE1 KRISHNA 90 92 95 98 95 470 942 SANTHOSH 90 85 86 81 85 427 85.43 MURALI 90 95 96 88 99 468 93.64 VINOD 85 86 75 95 96 437 87.45 HARI 90 95 96 98 90 469 93.8

S.NO EMP NAMEBASIC PAY HRA PF DA TA

TOTAL

1 KRISHNAN 35000 10000 500 3500 1000 490002 RAHUL 20000 9000 255 1500 1000 312453 RATAN 30000 8000 650 2500 1000 408504 MURLI 12000 10500 800 3600 1000 263005 CLIFF 17000 9500 940 2500 1000 29060

Result:

Thus the formula-editor operation is performed and the required output is obtained

using OpenOffice.org Calc.

Computer Science & Engineering Page 18

Page 19: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

SPREADSHEET – INCLUSION OF OBJECT, PICTURE AND GRAPHICS,

PROTECTING THE DOCUMENT

Aim:

To perform the insertion of objects, graphics and protecting the document in

OpenOffice.org Calc.

Algorithm:

1. Click Start > Programs > OpenOffice.rg > OpenOffice.org calc.

2. Enter the data.

3. Perform the insertion of objects using Insert > Object.

4. Click Insert > Picture to add pictures and graphics.

5. Select Tools > Protect Document > Document to protect the structure of the

document

6. Select Tools > Protect Document – Sheet to protect sheets from changes .

7. Use Tools > Protect Document then deselect sheet or document to unprotect sheet or

document.

8. Display the output.

Computer Science & Engineering Page 19

Page 20: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:

Result:

Thus the required operations are performed and the required output is obtained using OpenOffice.org Calc.

SORTING AND IMPORT/EXPORT FEATURES

Computer Science & Engineering Page 20

Page 21: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Aim:

To perform the sorting and import/export features in OpenOffice.org Calc.

Algorithm:

1. Click Start > Programs > OpenOffice.org > OpenOffice.org calc.

2. Enter the data.

3. Select the column or row then click Data > Sort.

4. Display the output for Sorting.

5. Click Start > Run.

6. Type Notepad and click OK.

7. Enter the contents as shown below:

a. "Sales Per Region"," Africa"," Asia"," Europe”, “Total"

b. "Jan",34,67,56,157

c. "Feb",36,87,78,201

d. "Mar",34,67,56,157

e. "Apr",36,87,78,201

f. "May",34,67,56,157

g. "Jun",36,87,78,201

h. "Total",210,462,402,

8. Click File > Save and Enter the Name as ‘Import.csv’ and Click Save.

9. Click Start > Programs > OpenOffice.org > OpenOffice.org calc.

10. Click File > Open and select the Import.csv file and Click Open.

11. The contents typed in Notepad will be available in Calc.

12. Click Start > Programs > OpenOffice.org > OpenOffice.org calc.

13. Enter the data similar to import contents in the Open Office Calc.

14. Choose File > Save as. You will see the Save as dialog.

15. In the File type field select the format "Text CSV".

16. Enter a Name as Export and Click Save.

17. The contents typed in Calc will be exported.

18. Verify the Exported contents by opening the file with Notepad.

Computer Science & Engineering Page 21

Page 22: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:

Computer Science & Engineering Page 22

Page 23: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Export.csv Notepad File

"Sales Per Region"," Africa"," Asia"," Europe","Total"

"Jan",34,67,56,157

"Feb",36,87,78,201

"Mar",34,67,56,157

"Apr",36,87,78,201

"May",34,67,56,157

"Jun",36,87,78,201

"Total",210,462,402,

Result:

Thus the required operations are performed and the required output is obtained

using OpenOffice.org Calc.

GREATEST AMONG THREE NUMBERS

Computer Science & Engineering Page 23

Page 24: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Aim:

To write a c program to find a greatest number among three numbers .

Algorithm:

1. open a new file

2. Get the three numbers from the user as input.

3. Find the greatest number form those three number.

4. Pint the greatest number.

Coding:

#include<stdio.h>

#include<conio.h>

Void main()

{

Int a,b,c;

Printf(“Enter the value of A”);

Scanf(“%d”,&a);

Printf(“Enter the value of B”)

Scanf(“%d”,&b);

Printf(“Enter the value of C”);

Scanf(“%d”,&c);

If(a>b && a>c)

Printf(“A is greater”);

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

Printf(“B is greater”);

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

Printf(“C is greater”);

}

Flowchart:

Computer Science & Engineering Page 24

Page 25: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:

Enter the value of A:10

Enter the value of B:20

Enter the value of C:30

C is greater.

Result:

Thus the C program for Greatest of three numbers has been executed and the required output has been obtained.

Computer Science & Engineering Page 25

Page 26: Foc Lab Manual

A

Stop

Case 3

Case 4

c=a*b

c=a/b

Case 2 c=a-b

Print cc=a+bCase 1

Start

Read a,b and ch

is chA

Print c

Print c

Print c

COMPUTER PRACTICES LABORATORY I

ARITHMETIC OPERATIONS

Aim:

To write a C program to perform a Arithmetic operations(+,-,*,/)

Algorithm:

1. Open a new file

2. Get the two numbers as input and operation to perform from the user

3. Perform the arithmetic operation as per the user’s input by using ‘CASE’

4. print the result

Flowchart:

Coding:

Computer Science & Engineering Page 26

Page 27: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

#include<stdio.h>

#include<conio.h>

void main()

{

int a,b,c,ch;

clrscr();

printf("Enter the value of A");

scanf("%d",&a);

printf("Enter the valur of B");

scanf("%d",&b);

printf("1.addition\n2.subtraction\n3.multiplication\ndivision");

printf("Enter your choice");

scanf("%d",&ch);

do

switch(ch)

{

case 1:

c=a+b;

printf("%d",c);

break;

case 2:

c=a-b;

printf("%d",c);

break;

case 3:

c=a*b;

printf("%d",c);

break;

case 4:

c=a/b;

printf("%d",c);

break;

}

Computer Science & Engineering Page 27

Page 28: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

while(ch>4);

getch();

}

Output:

Enter the value of A:12Enter the valur of B:12

1.addition2.subtraction3.multiplication4.Division

Enter your choice124

Result:

Thus the C program for Arithmetic operations have been executed and the required output has been obtained.

PASCAL’S TRIANGLE

Computer Science & Engineering Page 28

Page 29: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Aim:

To write a C program to print the Pascal’s triangle.

Algorithm:

1. Start.

2. Get the number of lines to print from the user.

3. Generate the triangle by using conditional loops.

4. Print the triangle.

5. Stop.

Flowchart:

Computer Science & Engineering Page 29

Start

Stop

Page 30: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Coding:

#include<stdio.h>

#include<conio.h>

void main()

{

int n=1,c=1,i,r,a=1,b=0;

clrscr();

printf("\t\t\tPASCAL's TRIANGLE");

printf("\n\nEnter the number of rows to print:");

scanf("%d",&r);

printf("\n\n");

while(n<=r)

{

while(a<r)

{

printf(" ");

a=a+1;

}

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

printf(" %d",i);

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

printf(" %d",i);

printf("\n");

c=c+2;

n=n+1;

b=b+1;

a=b+1;

}

getch();

}

Computer Science & Engineering Page 30

Page 31: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:

PASCAL's TRIANGLE

Enter the number of rows to print:5

1

2 3 2

3 4 5 4 3

4 5 6 7 6 5 4

5 6 7 8 9 8 7 6 5

Result:

Thus the C program for pascal’s triangle has been executed and the required output has been obtained.

FIBONACCI SERIES

Computer Science & Engineering Page 31

Page 32: Foc Lab Manual

Start

Read n

COMPUTER PRACTICES LABORATORY I

Aim:Write a C program to printa Fibonacci series for a limit.

Algorithm:1. Open a new file.2. Get the limit or length of the series from the user.3. find the elements of the series 4. Print the elements

Flowchart:

No

Yes

Coding:

#include<stdio.h>

Computer Science & Engineering Page 32

Assign f1=-1,f2=1,f3=0

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

c= a+b

Print c

a=bb=c

Stop

Page 33: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

#include<conio.h>main(){

int f1=-1,f2=1,f3,n,i;clrscr();printf("Enter the limit :");scanf("%d",&n);if(n<3){

printf("0");printf("\n1");

}else{

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

f3=f1+f2;f1=f2;f2=f3;printf("\n%d",f3);

}}

getch();

}

Output:

Enter the limit: 7

The series is….0112358

Result:Thus the program for Fibonacci series is executed and the required output is

obtained.

SWITCH CASE

Computer Science & Engineering Page 33

Page 34: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Aim:

To write a C program to perform the operations below:

Prime or not.

Reverse of the number.

Fibonacci Series for the limit.

Algorithm:

1. Open a new file

2. Get the number from the user.

3. Gets the choice of operation from the user as input using CASE.

4. Perform the appropriate operation on the given number.

5. Print the result.

Flowchart:

Computer Science & Engineering Page 34

A B

AB

C

Page 35: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Coding:

#include<stdio.h>

#include<conio.h>

void main()

{

int f1=-1,f2=1,f3,n,ch,i;

clrscr();

printf("Enter the value of n: ");

scanf("%d",&n);

printf(“1.Prime or Not\n2.Reverse of the number\n3.Fibonacci Series\

n4.Exit”);

q:printf("Enter your choice");

scanf("%d",&ch);

switch(ch)

{

case 1:

if(n<2)

Computer Science & Engineering Page 35

C

C CSTOP

Page 36: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

printf("the no is prime");else{

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

if(n%i==0)f=1;break;

}if(f==0)

printf("the no is prime");elseprintf("the no is not prime");

} break;case 2:

while(n>0)

{a=n%10;n=n/10;printf("%d",a);

}

break;

case 3:

if(n<3) {

printf("0");printf("\n1");

}else{

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

f3=f1+f2;f1=f2;f2=f3;printf("\n%d",f3);

}}

break;

case 4:

exit(0);

Computer Science & Engineering Page 36

Page 37: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

default:

printf(“Enter the Correct Choice:”);

goto q;

}

getch();

}

Output:

Enter the value of n: 13

Enter your choice: 1

The no is prime.

Result:

Thus the program is executed to perform the above operations and the output is

verified successfully.

SEARCHING AN ELEMENT IN AN ARRAY

Computer Science & Engineering Page 37

Page 38: Foc Lab Manual

STOP

START

READ n, a[]

COMPUTER PRACTICES LABORATORY I

Aim:To write a C program to search a element in a array.

Algorithm:1. To open a new file.2. Get a n number of elements from the user and store it in a array3. Get a element to be searched in the array form the user 4. Search a that particular element in the array by using the for loop.5. print the result.

Flowchart:

Coding:

#include<stdio.h>

Computer Science & Engineering Page 38

Page 39: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

#include<conio.h>main(){

int a[15],n,e,i,f=0;clrscr();printf("Enter the number of elements :");scanf("%d",&n);printf("Enter the elements.....");for(i=0;i<n;i++)

scanf("%d",&a[i]);printf("Enter the element to search :");scanf("%d",&e);for(i=0;i<n;i++){

if(e==a[i])f=1;

}if(f==1)

printf("%d is found",e);else

printf("%d is not found",e);

getch();}

Output:Enter the size of the array: 6Enter the elements….123456Enter the element to search: 66 is available in the array

Result:Thus the program for searching a element in the array is executed and the required

output is obtained.

MATRIX ADDITION

Computer Science & Engineering Page 39

Page 40: Foc Lab Manual

start

Read row, col

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

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

Read a[i][j]

A

B

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

COMPUTER PRACTICES LABORATORY I

Aim:To write a C program to perform matrix addtition.

Algorithm:1. To open a new file.2. Initialize the matrix3. Get the input matrix from the user4. Perform the matrix addition5. Print the output.

Flowchart:

FLOWCHART FOR MATRIX ADDITION

Computer Science & Engineering Page 40

C

Page 41: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Coding:

#include<stdio.h>

Computer Science & Engineering Page 41

for(j=0;j<col;j

for(i=0;i<row;i

Print c[i][j]

Stop

C

C

for(j=0;j<col;j

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

c[i][j]= ai][j]+b[i][j]

C

C

Page 42: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

#include<conio.h>main(){

int a[3][3],b[3][3],c[3][3];int i,j;clrscr();printf("Enter the elements of matrix A...");for(i=1;i<=3;i++){

for(j=1;j<=3;j++){

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

}printf("Enter the elements of matrix B...");for(i=1;i<=3;i++){

for(j=1;j<=3;j++){

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

}for(i=1;i<=3;i++){

for(j=1;j<=3;j++){

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

}printf("The result is.........");for(i=1;i<=3;i++){

for(j=1;j<=3;j++){

printf("\n%d",c[i][j]);}

}getch();

}

Output:Enter the matrix A:

Computer Science & Engineering Page 42

Page 43: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

1 2 31 2 31 2 3

Enter the matrix B:1 2 31 2 31 2 3

The resultant matrix is…..2 4 62 4 62 4 6

Result:Thus the program for matrix addition is performed and the required output is

obtained.

STRING CONCATENATION

Aim:

Computer Science & Engineering Page 43

Page 44: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

To write a C program to perform a string concatenation.

Algorithm:1. To open a new file.2. Get a two strings from the user.3. To find the length of the string by using strlen() function.4. To concatenate that strings 5. Print the output.

Flowchart:

Coding:

#include<stdio.h>#include<conio.h>

Computer Science & Engineering Page 44

Page 45: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

#include<string.h>void main(){

int a,b,c;char i,j;char s1[10],s2[10],s3[10];clrscr();printf("Enter the first string :");scanf("%s",s1);printf("Enter the second string :");scanf("%s",s2);a=strlen(s1);b=a+strlen(s2);for(i=0;i<a;i++)

s3[i]=s1[i];for(i=a;i<=b;i++)

s3[i]=s2[i-a];printf("\n\nAfter the concatenation:");printf("%s",s3);getch();

}

Output:

Enter the first stringUNITED INSTITUE

Enter the second stringOF TECHNOLOGY

Then the resultant string is…..UNITED INSTITUE OF TECHNOLOGY

Result:Thus the program for string concatenation is performed and the required output is

obtained.

STRUCTURES

Computer Science & Engineering Page 45

Page 46: Foc Lab Manual

stop

Print stu[i].rollno, stu[i].name, stu[i].mark1, stu[i].mark2, stu[i].mark3

A

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

read stu[i].rollno, stu[i].name, stu[i].mark1, stu[i].mark2, stu[i].mark3

A

struct student roll no: integer name[30]: character mark 1, mark 2mark 3, : integer

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

Read n

start

COMPUTER PRACTICES LABORATORY I

Aim:To write a C program to display the student information by using structures.

Algorithm:1. To open a new file.2. Get a student information from the user.3. To get the input query from the user4. Based on the user’s query reterive the information.5. Print the output.

Flowchart:

Coding:

Computer Science & Engineering Page 46

Page 47: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

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

struct student{

int rollno;char name[10];int mark1;int mark2;int mark3;

}stu[35];int n,i;clrscr();printf("Enter the number of student :");scanf("%d",&n);printf("\n\nEnter the student's roll no, name and marks...");for(i=1;i<=n;i++){

printf("\nRoll no:");scanf("%d",&stu[i].rollno);printf("Name:");scanf("%s",stu[i].name);printf("Mark1:");scanf("%d",&stu[i].mark1);printf("Mark2:");scanf("%d",&stu[i].mark2);printf("Mark3:");scanf("%d",&stu[i].mark3);

}printf("\n\t\tStudent details");printf("\nROLL_NO\tNAME\tTOTAL\tAVG");for(i=1;i<=n;i++){

printf("\n%d",stu[i].rollno);printf("\t%s",stu[i].name);printf("\t%d",(stu[i].mark1+stu[i].mark2+stu[i].mark3));printf("\t%d",((stu[i].mark1+stu[i].mark2+stu[i].mark3)/3));

}getch();

}

Output:

Enter the number of student : 2

Computer Science & Engineering Page 47

Page 48: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Enter the student's roll no, name and marks...Roll no: 101Name: Rajesh KMark1 : 85Mark2 : 90Mark3 : 95

Roll no: 102Name: Vimal LMark1 : 80Mark2 : 85Mark3 : 75

Student DetailsROLL_NO NAME TOTAL AVG

101 Rajesh K 270 90

102 Vimal L 240 80

Result:Thus the program for student information using structures is performed and the

required output is obtained.

RECURSIVE FUNCTION

Aim:

Computer Science & Engineering Page 48

Page 49: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

To write a C program to Perform a Factorial operation using recursive function.Algorithm:

1. Open a new file.2. Get a value from the user to find factorial.3. Perform the operation4. Print the output.

Flowchart:

Coding:

#include<stdio.h>

Computer Science & Engineering Page 49

Page 50: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

#include<conio.h>main(){

int n,f;clrscr();printf("Enter the number :");scanf("%d",&n);if(n==0)

printf("factorial of 0 is 1");else{

f=fact(n);printf("factorial of %d is :%d",n,f);

}getch();

}fact(int a){

int f=1,i;for(i=1;i<=a;i++)

f=i*fact(a-1);return f;

}

Output:Enter the number:5Factorial of the given number is:120

Result:Thus the program for Factorial using recursive function is performed and the

required output is obtained

WORKING WITH FILES

Computer Science & Engineering Page 50

Page 51: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Aim:

To write a program to perform read and write operations using files.

Algorithm:

1. Open a new file.

2. Enter the data in to the file.

3. Read t data from file.

4. Display the text.

5. Close the file.

Flowchart:

Coding:

#include <stdio.h>

Computer Science & Engineering Page 51

Page 52: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

#include<conio.h>main(){        FILE *fs, *ft ;        char ch ; char file1[30],file2[30];

fs = fopen ( “pr1.c”, “r” ) ;        if ( fs == NULL )        {               puts ( “Cannot open source file” ) ;               exit( ) ;        } printf(“\nData from the file is read\nPress Anykey to Write…..\n”);         ft = fopen ( “pr2.c”, “w” ) ;        if ( ft == NULL )        {               puts ( “Cannot open target file” ) ;               fclose ( fs ) ;               exit( ) ;        }

        while ( 1 )        {               ch = fgetc ( fs ) ;

               if ( ch == EOF )                      break ;               else                                           fputc ( ch, ft )  ;        }

        fclose ( fs ) ;        fclose (tprintf(“\nData is written in to the file “);

getch();

}

Computer Science & Engineering Page 52

Page 53: Foc Lab Manual

COMPUTER PRACTICES LABORATORY I

Output:

Data from the file is read

Press Any key to Write…..

Data is written in to the file

Result:

Thus the C program is executed to perform read and write operations in files and the output is obtained successfully.

Computer Science & Engineering Page 53