Computer Practice Laboratory Nirmala

download Computer Practice Laboratory Nirmala

of 47

Transcript of Computer Practice Laboratory Nirmala

  • 7/31/2019 Computer Practice Laboratory Nirmala

    1/47

    1

    COMPUTER PRACTICE LABORATORY - I MANUAL

    For First year B.E/B.Tech. Students (common to all branches)

    Anna UniversityMadurai

    DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

    COMPUTER PRACTICE LABORATORYI

  • 7/31/2019 Computer Practice Laboratory Nirmala

    2/47

    2

    SYLLABUS

    UNIT - I

    Introduction to Application Practical Exercises may be given in the Package application packages to

    acquire skills in word processing. Spread sheet and Power point.

    a) Word Processing1. Document creation, Text manipulation with Scientific notations.

    2. To create an advertisement in word

    3. To illustrate the concept of mail merging, importing images, tables in Word

    4. Drawing - flow Chart

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

    6. Formula - formula editor.

    b) Spread Sheet

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

    8. To create a spread sheet to analyze the marks of the students of a class and also to create appropriate

    charts.

    9. Sorting and Import / Export features.

    c) Power point

    10. To create the presentation for the department with power point using animation, Design Templates

    and Effective Presentation

    UNIT - II

    C Programming Basics

    Data types, Expression Evaluation, Condition Statements, Operators, and Expressions, IO Formatting,

    Decision Making, Looping

    1. Operators and Expressions.

    2. Control Structures.

    3. Arrays

    4. Functions

    5. Pointers

    6. Pointers and Functions

    7. Structures and Unions

    8. Files

  • 7/31/2019 Computer Practice Laboratory Nirmala

    3/47

    3

    CONTENTS

    S.No Date TopicsPage

    No

    Marks

    obtained

    Staff

    signature

    UNIT - I

    1 Document creation Text manipulation withScientific notations 4

    2 Advertisement in Word 6

    3Mail merge, Importing image, Tables in

    Word7

    4 Drawing - Flow Chart 12

    5 Chart - Line, XY, Bar and Pie 13

    6 Formula - formula editor 16

    7

    Spread sheet - inclusion of object, Picture

    and graphics, protecting the document and

    sheet

    18

    8To analyze the marks of the students and

    chart creation19

    9 Sorting and Import / Export features 20

    10 PowerPoint presentation 24

    UNIT - II

    11DataTypes,Expression,Evaluation,Condition

    Statements, Operators25

    12 Sales Report 28

    13 Matrix Multiplication 30

    14 Alphabetical orders 32

    15 Fibonacci series & Factorial -functions 34

    16 Accessing array using pointers 37

    17 Pointers and Functions 39

    18 Mark sheet using structures 41

    19 Files 44

  • 7/31/2019 Computer Practice Laboratory Nirmala

    4/47

    4

    Ex.No: 1 DOCUMENT CREATION TEXT MANIPULATION WITH

    Date: SCIENTIFIC NOTATIONS

    Aim

    To create a document and manipulate text with scientific notations.

    Procedure

    1. Select StartProgramsMS-Office Microsoft word2. Now new document window will be opened3. Type the contents within the document and Perform the operations

    Like

    a) Make some text bold type, underline & make italicb) Correct spellings & save the document with suitable namec) Change the text with different font types & size

    (I) COMPUTER

    Definition

    Computer is an electronic machine which performs a particular task.

    Parts of the Computer

    It has three components. They are

    i. CPUii. Input unit andiii. Output unit.

    CPU is the central Processing Unit which consists of three other units like ALU, Memory unit

    and Control unit. ALU means Arithmetic and Logic Unit which performs all arithmetic and logical

    operations. Memory unit is to store all programs and data. Control unit controls the overall system.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    5/47

    5

    (II) Fundamentals of Computing

    Fundamentals of computing

    Fundamentals of computing

    ABS TEXTILES,

    45,Car Street,

    Tiruchengode-637 204.

    04288-233871.

    4. Search for the word Computer and replace it with Computer System5. Type the following at the end of the document:(A+B)

    2=A

    2+B

    2+2AB

    H2+O2H2O

    a+b=c

    6. Save the document as Filename.doc7. Close the document

    Result

    Thus the document has been created and manipulated text with scientific notations..

  • 7/31/2019 Computer Practice Laboratory Nirmala

    6/47

    6

    Ex.No:2 ADVERTISEMENT IN WORD

    Date:

    Aim

    To create an advertisement in Microsoft Word.

    Procedure

    1. Click start button all programs, Microsoft Office and then Microsoft word.

    2. Then type the given advertisement.

    3. In order to create a document, the text has to be typed in. As the text is typed in, it can be seen in the

    document window. The texts will automatically word-wrap to the next line in case it does not fit in the

    current line.

    4. Using the alignment keyword center, the words in the documents is aligned center.

    5. Using bold, italic and underline, we can highlight certain word which will be perfect for the

    advertisement.

    6. We can also insert the word art to make the heading a little bolder and attractive.

    7. Moreover MS-WORD offers a lot of facilities to format our documents like margin adjustment,

    alignment or text. Changing the text attributes, customizing, paragraphs, changing font styles sizes,

    inserting bullets and numbering, inserting header and footers, creating a table, inserting a graphic in a

    documents

    8. The above facilities make our advertisement more attractive.

    Result

    Using MS-Word, an attractive advertisement is created successfully.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    7/47

    7

    Ex. No: 3 MAIL MERGES AND LETTER PREPARATION

    Date:

    Aim

    To prepare letters and send it to multiple recipients by using Mail merge.

    Procedure

    1. Open the new document and type the following letterFrom

    The Head of the Department

    Department of CSE

    JKK Munrajah College of Technology,

    T.N.Palayam.

    To

    Our Students are interested to visit your company on the first week of Next month. I kindly

    request you to give permission to us.

    Thanking You,

    Yours faithfully,

    HOD

    2. Select ToolsLetters and MailingsMail Merge Wizard3. Select document type as Letters4. Select starting document as Use the current document5. Select recipients as Type a new list6.

    Select Create7. New address list window appears

    8. Type the details which you want9. Save the address list as my address and go to next10.Select Write your letter11.Place the cursor at the To address in the document12.Select the Address block... and click OK13.Select the Greet line... and click OK14.Now the document looks like...

  • 7/31/2019 Computer Practice Laboratory Nirmala

    8/47

    8

    From

    The Head of the Department

    Department of CSE

    JKK Munrajah College of Technology,

    T.N.Palayam.

    To

    AddressBlock

    GreetingLine

    Our Students are interested to visit your company on the first week of Next month. I kindly

    request you to give permission to us.

    Thanking You,

    Yours faithfully,

    HOD

    15.Select Preview your letters16.Now the letter is ready for multiple recipients.17.See all letters by clicking >> in the mail merge window.

    Output

    From

    The Head of the Department

    Department of CSE

    JKK Munrajah College of Technology,

    T.N.Palayam.

    To

    Mr. Rajan

    HCL Corporation

    Chennai

    Dear Mr.Rajan,Our Students are interested to visit your company on the first week of Next month. I

    kindly request you to give permission to us.

    Thanking You, Yours faithfully,

    HOD

  • 7/31/2019 Computer Practice Laboratory Nirmala

    9/47

    9

    From

    The Head of the Department

    Department of CSE

    JKK Munrajah College of Technology,

    T.N.Palayam.

    To

    Mr. Karthick

    CTS Technologies

    Chennai

    Dear Mr.Karthick,

    Our Students are interested to visit your company on the first week of Next month. I kindly

    request you to give permission to us.

    Thanking You,

    Yours faithfully,

    HOD

    Result

    Thus the letter has been created for multiple recipients using mail merge.

    IMORTING IMAGE

    Aim

    To import an image in word processing.

    Procedure

    1. Open the new document2. Select Insert menu bar3. Select Picture and choose the required picture4. Insert the Picture in to the document

  • 7/31/2019 Computer Practice Laboratory Nirmala

    10/47

    10

    Result

    The importing an image in word processing is done successfully.

    WORKING WITH TABLES

    Aim

    To create a table and use table formats and conversion operations.

    Procedure

    1. Open the new document2. Select Table menu bar, then choose insert table option

    3. Type the following contents within the table and use table formats

  • 7/31/2019 Computer Practice Laboratory Nirmala

    11/47

    11

    S.No Roll No Name M1 M2

    1 1001 Devika 88 84

    2 1002 Kavitha 87 97

    3 1003 Bhuvana 90 98

    4 1004 Prabu 89 88

    5 1005 Rani 79 93

    4. Select TableConvertTable to Text option to convert a table into text by separating commas and

    Select Comma in the Table to Text option.

    S.No, Roll No, Name, M1, M2

    1, 1001, Devika, 88, 84

    2, 1002, Kavitha, 87, 97

    3, 1003, Bhuvana, 90, 98

    4, 1004, Prabu, 89, 88

    5, 1005, Rani, 79, 93

    5. Reverse the text into table by selecting TableConvertText to Table option.S.No Roll No Name M1 M2

    1 1001 Devika 88 84

    2 1002 Kavitha 87 97

    3 1003 Bhuvana 90 98

    4 1004 Prabu 89 88

    5 1005 Rani 79 93

    Result

    Thus the table has been created and conversion operation is performed.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    12/47

    12

    Ex. No: 4 DRAWING - FLOWCHART

    Date:

    Aim

    To draw a flowchart in word processing.

    Procedure

    1. Select InsertshapesFlowchart

    2. Select the Shape and draw the flowchart

    Result

    Thus the flowchart has been drawn using Auto shape tools

    Start

    Read x,n

    For( i=1; i

  • 7/31/2019 Computer Practice Laboratory Nirmala

    13/47

    13

    Ex.No: 5 MS-Word -CHART

    Date:

    LINE CHART

    Aim

    To create a Line chart in Excel.

    Procedure

    1. Type the followingRoll No Name Weight

    1001 aaa 63

    1002 bbb 52

    1003 ccc 46

    1004 ddd 58

    1005 eee 60

    2. Select all data in the document3. Select InsertChart4. Choose chart type as Line5. Type the chart title as Weight chart6. Type X-axis title as Name and RollNo7. Type Y-axis title as Weight8. Click ok

    Output

    Weight chart

    010

    20

    30

    40

    50

    60

    70

    aaa bbb ccc ddd eee

    1001 1002 1003 1004 1005

    Name and Rollno

    Weight

    Weight

  • 7/31/2019 Computer Practice Laboratory Nirmala

    14/47

    14

    XY CHART

    Aim

    To create a XY chart in MS-Word.

    Procedure

    1. Select all data in the Document.2. Select InsertChart3. Choose chart type as XY4. Type the chart title as Weight chart5. Type X-axis title as Name and RollNo6. Type Y-axis title as Weight7. Click OK

    Output

    BAR CHART

    Aim

    To create a Bar chart in Excel.

    Procedure

    1. Select all data in the worksheet2. Select InsertChart3. Choose chart type as Column and select Next and select Next4. Type the chart title as Weight chart5. Type X-axis title as Name and RollNo6. Type Y-axis title as Weight7. Click OK

    Weight chart

    0

    20

    40

    60

    80

    0 2 4 6

    Name and RollNo

    Weight

    Weight

  • 7/31/2019 Computer Practice Laboratory Nirmala

    15/47

    15

    OUTPUT

    PIE CHART

    Aim

    To create a Pie chart in Excel.

    Procedure

    1. Select all data in the worksheet2. Select InsertChart3. Choose chart type as Pie4. Type the chart title as Weight chart5. Click OK

    Output

    Result

    Thus the chartsLine, XY, Bar and Pie were created.

    Weight Chart

    0

    10

    20

    30

    40

    5060

    70

    aaa bbb ccc ddd eee

    1001 1002 1003 1004 1005

    Name and RollNo

    Weight

    Weight

    Weight chart

    1001 aaa

    1002 bbb

    1003 ccc

    1004 ddd

    1005 eee

  • 7/31/2019 Computer Practice Laboratory Nirmala

    16/47

    16

    Ex. No: 6 MS-WORDFORMULA EDITOR

    Date:

    Aim

    To perform some calculation in MS-Word by using Formula editor.

    Procedure

    1. Type the following in MS-Word

    RollNo Name English Maths Computer

    1 vimala 63 57 62

    2 Priya 52 56 54

    3 Divya 96 89 90

    4 Sudha 84 87 88

    5 Kavi 75 76 74

    Total

    Average

    2. Select layoutdataformula

  • 7/31/2019 Computer Practice Laboratory Nirmala

    17/47

    17

    Output

    RollNo

    Name English Maths Computer

    1 vimala 63 57 62

    2 Priya 52 56 54

    3 Divya 96 89 90

    4 Sudha 84 87 88

    5 Kavi 75 76 74

    Total 370 365 368

    Average 123.33 121.67 122.67

    Result

    Thusthe total and average were calculated using Formulas.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    18/47

    18

    Ex. No: 7 SPREAD SHEETINCLUSION of OBJECT,

    Date: PICTURE and PROTECTION OF DOCUMENTS

    Aim

    To include an object, Picture and graphics in a document.

    Procedure

    1. Select InsertObject2. Choose Object type as Bitmap Image and Click OK3. Now, Draw an object within the displayed window and Press Esc or click any other cell4. Select InsertPictureFrom file5. Type the filename to include as a Picture and Click Insert6. Now, the picture is included

    Output

    PROTECTING THE DOCUMENT AND SHEET

    Aim

    To protect a document and worksheet.

    Procedure

    1. Select ToolsProtectionProtect Sheet2. Type the Password to protect sheet3. Choose Insert Rows, Insert Columns, Delete Rows and Delete Columns4. Reenter the password again5. Now, the data cant be removed from/inserted into the cell6. To unprotect the sheet, Select ToolsProtectionUnprotect Sheet

    Result

    Thus the object and picture were included and the worksheet is protected.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    19/47

    19

    Ex. No: 8 SPREADSHEET-CHARTS

    Date:

    LINE CHART

    Aim

    To create a Line chart in Excel.

    Procedure

    9. Type the followingRoll No Name Weight

    1001 aaa 63

    1002 bbb 52

    1003 ccc 46

    1004 ddd 58

    1005 eee 60

    10.Select all data in the worksheet11.Select InsertChart12.Choose chart type as Line and select Next and select Next13.Type the chart title as Weight chart14.Type X-axis title as Name and RollNo15.Type Y-axis title as Weight16.Click Next17.Click Finish

    Output

    Weight chart

    0

    1020

    30

    40

    50

    60

    70

    aaa bbb ccc ddd eee

    1001 1002 1003 1004 1005

    Name and Rollno

    Weight

    Weight

  • 7/31/2019 Computer Practice Laboratory Nirmala

    20/47

    20

    XY CHART

    Aim

    To create a XY chart in Excel.

    Procedure

    8. Select all data in the worksheet9. Select InsertChart10.Choose chart type as XY and select Next and select Next11.Type the chart title as Weight chart12.Type X-axis title as Name and RollNo13.Type Y-axis title as Weight14.Click Next15.Click Finish

    Output

    BAR CHART

    Aim

    To create a Bar chart in Excel.

    Procedure

    8. Select all data in the worksheet9. Select InsertChart10.Choose chart type as Column and select Next and select Next11.Type the chart title as Weight chart12.Type X-axis title as Name and Roll No13.Type Y-axis title as Weight14.Click Next15.Click Finish

    Weight chart

    0

    20

    40

    60

    80

    0 2 4 6

    Name and RollNo

    Weight

    Weight

  • 7/31/2019 Computer Practice Laboratory Nirmala

    21/47

    21

    Output

    PIE CHART

    Aim

    To create a Pie chart in Excel.

    Procedure

    6. Select all data in the worksheet7. Select InsertChart8. Choose chart type as Pie and select Next and select Next9. Type the chart title as Weight chart10.Click Next11.Click Finish

    Output

    Result

    Thus the chartsLine, XY, Bar and Pie were created.

    Weight Chart

    0

    10

    20

    30

    4050

    60

    70

    aaa bbb ccc ddd eee

    1001 1002 1003 1004 1005

    Name and RollNo

    Weight

    Weight

    Weight chart

    1001 aaa

    1002 bbb

    1003 ccc

    1004 ddd

    1005 eee

  • 7/31/2019 Computer Practice Laboratory Nirmala

    22/47

    22

    Ex.No. 9 SPREAD SHEETSORTING & IMPORT/EXPORT

    Date: FEATURES

    Aim

    To Sort the given data in the Excel worksheet.

    Procedure

    1. Type the following in Excel

    5 vimala 500

    4 Priya 400

    3 Divya 300

    2 Sudha 200

    1 Kavi 100

    2. Select the typed text

    3. Choose DataSort

    4. Choose Sort by as Column A and Ascending

    5. Click OK

    Now it appears in the sorted order.

    Output

    1 Kavi 100

    2 Sudha 200

    3 Divya 300

    4 Priya 400

    5 Vimala 500

  • 7/31/2019 Computer Practice Laboratory Nirmala

    23/47

    23

    IMPORTING FEATURES

    Aim

    To Import the given data into Excel.

    Procedure

    1. Create a text file named text.txt and type the following1001 aaa 10

    1002 bbb 20

    1003 ccc 30

    1004 ddd 40

    1005 eee 50

    2. Start Microsoft Excel: Go to StartProgramsMicrosoft Excel3. Click on FileOpen4. Open Text file text.txt5. The text Input Wizard will now appear with two choices: Delimited or Field width6. Select Delimited and Click Next7. Select Space as the delimiter and none as the Text qualifier and Click Next8. Click Finish.9. File is now in Excel10.Save the file in Excel format

    Result

    Thus the given data are sorted and imported a text file into Excel.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    24/47

    24

    Ex. No: 10 POWER POINT PRESENTATIONS

    Date:

    Aim:

    To create a power point presentation for the department using animation, design templates andeffective presentation

    Algorithm:

    1. Start the power point presentationGo to start programs Microsoft office PowerPoint 2007

    2. Open a new presentation and save it under some names.Go to file new presentation new slide

    3. I) create a new slide with text and images.ii) Implement using the text box and insert image option to achieve these.

    iii) Add several slides with some text, images, sound etc (multimedia).

    4. Use the design templates to make the presentation an effective one.Use the design templates option to make it effective one

    5. Use the transition techniques to make that presentation in an graphical view6. Save it and run the show using f5 key.

    OUTPUT

    Result:

    Thus the presentation created for the department with power point using animation,

    design templates and effective presentation.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    25/47

    25

    Ex. No: 11 DATA TYPES, EXPRESSION EVALUATION AND CONDITIONAL

    STATEMENTS

    Date:

    Aim

    To write a C program to print the data types, expression evaluation and conditional statements.

    Algorithm

    Step-1: Start the program

    Step-2: Enter the values of a,b,c

    Step-3: Calculate d=a+b+c

    Step-4: Read the value of d

    Step 5; Calculate avg=d/3

    Step 6: Print the values: avg,d

    Step-7: Stop

    Data Types

    Program

    #include

    #include

    void main ()

    {

    int a, b, c, d;

    float average;

    printf(\n Enter the values:);

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

    d=a+b+c;

    printf(\n Total Value = %d,d);

    average=d/3;

    printf(\n Average of 3 numbers = %f, average);

    getch();

    }

  • 7/31/2019 Computer Practice Laboratory Nirmala

    26/47

    26

    OUTPUT

    Enter the values: 2 4 7

    Total value =13

    Average of three numbers=4.3333

    EXPRESSION EVALUATION AND CONDITIONAL STATEMENTS

    Algorithm

    Step-1: Start the program

    Step-2: Enter the values of a,b,c

    Step-3: Calculate add e=a+b+c

    Calculate multi f=(a*b)*c

    Calculate div g=a/b

    Calculate total=e+f+g

    Calculate ans=((a+b)/c)*a

    Step-4: Print the values: e,f,g,total,ans

    Step:5 If total>ans

    Print total greater ans\

    Else

    Print ans greater total

    Step-6: Stop

    PROGRAM

    #include

    #include

    void main()

    {

    float a,b,c,add,multi,div,total,ans,d;

    clrscr();

    printf(\n Enter the values:);

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

    add=a+b+c;

  • 7/31/2019 Computer Practice Laboratory Nirmala

    27/47

    27

    multi=(a*b)*c;

    div=a/b;

    total=add+multi+div;

    ans=((a+b)/c)*a;

    if(total>ans)

    {

    printf(\n Total is greater than ans);

    else

    printf(\n Ans is greater than total):

    }

    printf(\n Addition = %f,add);

    printf(\n Multiplication = %f,multi);

    printf(\n Division = %f, div);

    printf(\n Total = %f,total);

    printf(\n Answer = %f, ans);

    getch();

    }

    Output:

    Enter the values 3.2,8,4

    Addition = 15.2

    Multiplication = 102.4

    Division = 0.4

    Total = 118

    Answer = 8.96

    Total is greater than ans

    Result

    Thus the program to print data types,expression evaluation and conditional statements were written and

    executed successfully.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    28/47

    28

    Ex.No. 12 SALES REPORT

    Date.

    Aim

    To write a C program to prepare and print the sales report.

    Algorithm

    Step-1: Start the program

    Step-2: Read the number of products n

    Step-3: Setup a loop for n products

    Step-4: Read the productID, qty and price

    Step-5: totalqty*price

    Step-6: Check if qty100 or qty250 or qty500 or qty1000 then calculate commtotal*30/100

    Step-11: Setup a loop and print the results

    Step-12: Stop

    Program

    #include

    main()

    {

    int i,j,pid[10],price[10],qty[10],n,total[10],comm[10];

    clrscr();

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

    scanf("%d",&n);

    printf("Enter Product ID, Quantity and Price : ");for(i=0;i

  • 7/31/2019 Computer Practice Laboratory Nirmala

    29/47

    29

    comm[i]=total[i]*20/100;

    else if(qty[i]>500||qty[i]

  • 7/31/2019 Computer Practice Laboratory Nirmala

    30/47

    30

    Ex.No. 13 MATRIX MULTIPLICATION

    Date.

    Aim

    To write a C program to perform matrix multiplication.

    Algorithm

    Step-1: Start the program

    Step-2: Read the number of rows and columns of matrices A and B

    (r1,c1) & (r2,c2)

    Step-3: If c1 = r2 then do the following

    Step-3.1: Setup a loop and read the elements of matrix A

    Step-3.2: Setup a loop and read the elements of matrix B

    Step-3.3: Multiply two matrices by

    C[i][j] C[i][j] + A[i][k] * B[k][j];

    Step-3.4: Print the resultant matrix C

    Step-4: else Print c1 and r2 are not equal

    Step-5: Stop.

    Program

    #include

    main()

    {

    int r1,c1,r2,c2,i,j,k;

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

    clrscr();

    printf("Enter the size of the A matrix : ");

    scanf("%d%d",&r1,&c1);

    printf("Enter the size of the B matrix : ");

    scanf("%d%d",&r2,&c2);

    if(c1==r2)

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

    for(i=0;i

  • 7/31/2019 Computer Practice Laboratory Nirmala

    31/47

    31

    for(j=0;j

  • 7/31/2019 Computer Practice Laboratory Nirmala

    32/47

    32

    Ex.No. 14 ALPHABETICAL ORDERS

    Date.

    Aim

    To write a C program to arrange names in alphabetical order.

    Algorithm

    Step-1: Start the program

    Step-2: Read the number of names n

    Step-3: Setup a loop for n times

    Step-4: Read the names

    Step-5: Setup a loop i from 0 to n-1

    Step-6: Setup a loop j from i+1 to n-1

    Step-7: If (name[i] > name[j]) then swap them.

    Step-8: Setup a loop for n times

    Step-9: Print the sorted names

    Step-10: Stop.

    Program

    #include

    main()

    {

    int i,j,k,n;

    char name[10][20],temp[10];

    clrscr();

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

    scanf("%d",&n);printf("Enter %d names : \n",n);

    for(i=0;i

  • 7/31/2019 Computer Practice Laboratory Nirmala

    33/47

    33

    strcpy(name[j],temp);

    }

    printf("The sorted names are : ");

    for(i=0;i

  • 7/31/2019 Computer Practice Laboratory Nirmala

    34/47

    34

    Ex.No. 15 FIBONACCI SERIES & FACTORIAL -FUNCTIONS

    Date.

    Aim

    To write a C program to print the Fibonacci series and to calculate the factorial of the given number

    using functions.

    Algorithm

    Step-1: Start the program

    Step-2: Print the menu 1. Fibonacci 2. Factorial

    Step-3: Read the choice

    Step-4: If choice=1

    Step-4.1 : Read the number of terms n

    Step-4.2 : Call the function fibonacci(n)

    Step-5: If choice=2

    Step-5.1 : Read the number to compute factorial n

    Step-4.2 : Call the function factorial(n)

    Step-6: Stop.

    Function fibonacci()

    Step-1: Initialize 0 to f1 and 1 to f2

    Step-2: if n

  • 7/31/2019 Computer Practice Laboratory Nirmala

    35/47

    35

    else

    return n*factorial(n-1)

    Program

    #include

    void fibonacci(int n)

    {

    static int f1=0,f2=1;

    int t;

    if(n

  • 7/31/2019 Computer Practice Laboratory Nirmala

    36/47

    36

    break;

    case 2: printf("Enter the number to compute factorial : ");

    scanf("%d",&n);

    printf("Factorial of %d is : %d\n",n,fact(n));

    break;

    case 3: exit(0);

    break;default: printf("Invalid choice!!!");

    }

    }

    getch();

    }

    Output

    1.Fibonacci series

    2.Factorial

    3.Exit

    Enter the choice : 1

    Enter the number of terms : 10

    Fibonacci sequence :

    0 1 1 2 3 5 8 13 21 34

    1.Fibonacci series

    2.Factorial

    3.Exit

    Enter the choice : 2

    Enter the number to compute factorial : 5

    Factorial of 5 is : 120

    Result

    Thus the program for printing Fibonacci series and computing of factorial for a given number was

    written and executed successfully.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    37/47

    37

    Ex.no: 16 PRINTING THE ELEMENT OF AN ARRAY USING POINTERS

    Date:

    Aim

    To print the elements of an array pointers

    Algorithm

    Step-1: Start the program

    Step-2: Read the numbers using for loop and store it in an array

    Step-3: Assign a pointer variable

    Step-4: Assign pointer_variable=&x[0]

    Step-5: Print *(pointer_variable+i) using for loop

    Step-6: End the program.

    Program

    #include

    #include

    void main()

    {

    int i,n,a[10];

    Int *ipa;

    clrscr();

    printf(enter the number of elements:);

    scanf(%d,&n);

    printf(enter the elements one by:);

    for(i=0;i

  • 7/31/2019 Computer Practice Laboratory Nirmala

    38/47

    38

    printf(%d\n,*ipa);

    }

    getch();

    }

    Output:

    Enter the number of elements: 5

    Enter the elements one by one:

    12

    21

    26

    58

    78

    The elements present in the array are:

    12

    21

    26

    58

    78

    Result

    Thus the array of an elements are printed successfully.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    39/47

    39

    Ex.No: 17 SWAP TWO NUMBERS USING POINTERS AND FUNCTIONS

    Date:

    AIM

    To write a program to swap two number using pointer and functions

    ALGORITHM

    Step-1 Start the program

    Step-2 Enter the two numbers

    Step-3 Call the display function

    Step-4 Pass the address of the two numbers of the Calling

    Step-5 Get the address in the Calling function in the pointer

    Step-6 swap the number using temporary variable

    Step-7 Print the swamped values in the main function

    Step-8 Stop

    PROGRAM

    //SWAP THE NUMBER USING FUNCTIONS AND POINTERS

    #include

    main()

    {

    int x,y;

    printf(nEnter the two numbers );

    scanf( %d %d,&x,&y);

    printf(nThe entered number for x and y are,x=%dty=%d,x,y);

    display(&x,&y);

    printf(nAfter the swapping the value of,x=%dty=%d,x,y);

    }

    Display(int *a,int *b)

  • 7/31/2019 Computer Practice Laboratory Nirmala

    40/47

    40

    {

    int t;

    t=*a;

    *a=*b;

    *b=t;

    }

    OUTPUT:

    Enter the two numbers10 20

    The entered number for x and y are, x=10 y=20

    After the swapping the value of, x=20 y=10

    Result

    The elements are swapped using arrays and functions successfully.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    41/47

    41

    Ex.No. 18 MARK SHEET USING STRUCTURES

    Date.

    Aim

    To write a C program to print the mark sheet of n students using structures.

    Algorithm

    Step-1: Start the program

    Step-2: Read the number of students n

    Step-3: Setup a loop for n students

    Step-4: Read Rollno, Student name and six subject marks

    Step-5: Calculate the total and average

    Step-6: If any one subject mark is less than 50 then grade = fail

    Step-7: If average>=75 then grade=Distintction

    Step-8: If average=60 then grade=Firstclass

    Step-9: If average=50 then grade=Secondclass

    Step-10: Print all the student details

    Step-11: Stop.

    Program

    #include

    struct class

    {

    int rno,m[6],tot;

    char name[10], grade[12];

    float avg;

    }s[10];

    main(){

    int i,j,n;clrscr();

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

    scanf("%d",&n);

    for(i=1;i

  • 7/31/2019 Computer Practice Laboratory Nirmala

    42/47

    42

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

    printf("\nStudent name ");

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

    printf("Enter 6 subject marks : ");

    scanf("%d%d%d%d%d%d",&s[i].m[1],&s[i].m[2],&s[i].m[3],&s[i].m[4],&s[i].m[5],&s[i].m[6]);

    s[i].tot=s[i].m[1]+s[i].m[2]+s[i].m[3]+s[i].m[4]+s[i].m[5]+s[i].m[6];

    s[i].avg=s[i].tot/6;

    if(s[i].m[1]

  • 7/31/2019 Computer Practice Laboratory Nirmala

    43/47

    43

    Enter the details for student 3 :

    Rollno 3

    Student name suji

    Enter 6 subject marks : 45 56 67 76 72 56

    Student Mark List

    R.No Name Total Average Grade

    ====================================

    1 kavi 495 82.000000 Distinction

    2 prabu 549 91.000000 Distinction

    3 suji 372 62.000000 Fail

    Result

    Thus the program for printing students mark list using structures was written and executedsuccessful.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    44/47

    44

    Ex.No:19 EMPLOYEE DETAILS USING FILES

    Date:

    AIM :

    To write a program of employee details handling file by using fscanf() and fprintf().

    ALGORITHM

    Step-1 Start

    Step-2 read filename

    Step-3 open a file, filename

    Step-4 read n

    Step-5 Set a loop to get name, salary and age

    Step-6 read name, salary, age from a file

    Step-7 print name, salary, and age into the file

    Step-8 close file fp1

    Step-9 End

    PROGRAM

    #Include

    #Include

    void main()

    {

    FILE *fpl;

    int age,i,n;

    char filename[25],name[25];

    float salary;

    clrscr();

    printf(Enter the file name : );

    scanf(%s,filename);

    fp1=fopen(filename,w);

  • 7/31/2019 Computer Practice Laboratory Nirmala

    45/47

    45

    printf(Enter the Number of employee : );

    scanf(%d,&n);

    printf(Enter the Nae, Salay and Age:\n);

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

    {

    fscanf(stdin,%s%fd,&name,&salary,&age);

    fprintf(fp1,%s\t%f%d\n,name,salary,age);

    }

    fclose(fp1)

    fprintf(stdout, \n\n)

    fp1 =fopen(filename,r);

    printf(name salary age\n);

    printf(\n);

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

    {

    fscanf(fp1,%s %f %d,name,&salary,age);

    fprintf(stdout,%s\t %8.2f\t %d\n,name,salary,age);

    }

    getch();

    fclose(fp1)

    }

    OUTPUT:

    Enter the filename : vrb

    Enter the Number of employee : 3

    Enter the Name, Salary and Age:

    Venkat 10000 24

    Ragu 15000 29

    Shankar 20000 32

  • 7/31/2019 Computer Practice Laboratory Nirmala

    46/47

    46

    Name salary age

    Venkat 10000 24

    Ragu 15000 29

    Shankar 20000 32

    Result:

    The employment details given using files successfully.

  • 7/31/2019 Computer Practice Laboratory Nirmala

    47/47

    47