Wednesday 8 May 2013

FUNDAMENTAL OF COMPUTER PRACTICE LABORATORY - FOC

Department of Information Technology
         2011 Regulations – I Semester
           Common to ALL Branches
COMPUTER PRACTICE LABORATORY
                                                    LIST OF EXERCISES
a) Word Processing
1. Document creation, Text manipulation with Scientific notations.
2. Table creation, Table formatting and Conversion.
3. Mail merge and Letter preparation.
4. Drawing - flow Chart
b) Spread Sheet
5. Chart - Line, XY, Bar and Pie.
6. Formula - formula editor.
7. Spread sheet - inclusion of object, Picture and graphics, protecting the  
    Document and sheet.
8. Sorting and Import / Export features.
Simple C Programming
9. Data types, Expression Evaluation, Condition Statements.
10. Arrays
11. Structures and Unions
12. Functions


MICROSOFT WORD

AIM:
To create a document that reflects the newspaper format using Microsoft word.

          Word processor is used to produce documents for business or personal use such as newsletter, reports, letters and essays. We might say that a word processor is an intelligent typewriter. We can type a whole page, make corrections (editing), use up paragraphs in different styles and shapes and columns (formatting) and also check spelling, find and insert synonyms for a word (Thesaurus) and process it in many more ways before we actually put that page to print.
FEATURES OF WORD PROCESSOR
The following are the main features of a word processor:
    Fast
    Editing features
    Permanent storage
    Formatting features
    Graphics
CREATING A WORD DOCUMENT
PROCEDURE:
    To enter Microsoft word, Click “start” button then click “program” from “programs” menu then click “Microsoft word”
    For opening a word document do the following. Click “file” menu from the menu bar. From this file menu click “new” option. This will display the new document.
    Then for the newspaper format there must be a “header and footer” for giving heading and page number. This is done by clicking “view” from the menu bar, from this click “header and footer” option.
    Then enter the heading in the header portion and change the “font size” to big size and then click “B” button on formatting tool bar so that the header appears bold.
    Divide page into columns by clicking the format from the menu bar. Then click “columns” from the menus available under format. In this step the page is divided into your optional columns.
    Then enter the text. To insert a picture in between the text, click “insert” from the menu, then click picture and then clip art. From this clip art we can insert any picture.
    To insert symbols that are not found in the keyboard, click “insert” from the menu, then click “symbols”.
    After adding the text to the document, save the document by clicking the “file” from the menu bar and click ”save” .When we save the document for the first time  name is to be entered and click “save”















 EXERCISE 1: Create the following document
THE HINDU
FAKE STAMP PAPERS SEIZED

Two persons were arrested and counterfeit stamp papers seized following  a raid conducted on a house in Coimbatore
A release here  said a  special  team       The team also found
Found counterfeit stamp papers of         counterfeit currency.
Value Rs50000 and Rs1000.

















EXERCISE 2:
Insert the following mathematical formula and equations in the document
(a+b)(a-b)=a2-b2
(a+b)2=a2+b2+2ab
2H2+O2->2H2O

Insert the symbols like µ, ∞,α in your document

















EXERCISE 3:
 To create a resume. Sample document is given below.
RESUME
Name
Address                                        Contact details with corresponding symbols
Objectives:

Educational Qualification:

Extra curricular activities:

Co-curricular activities:

Hobbies:

Personal profile:

Declaration:
Thanking you,
Yours truly,
Result:
Thus the above experiment has been created Successfully.























CREATING A TABLE
AIM:
To create a table using Microsoft word.
PROCEDURE:
    To enter Microsoft word, Click “start” button then click “program” from “programs” menu then click “Microsoft word”
    For opening a word document do the following. Click “file” menu from the menu bar. From this file menu click “new” option. This will display the new document.
    Enter the heading, change the font size. Click the “B” button on the formatting tool bar so that the heading appears bold.
    To change the font colors click A button on the drawing tool bar and select the required colors.
    To insert a table click “Table” from the menu, then click “insert”, then click “table”. Specify the required number of rows and columns and the table gets inserted.
    After adding the text to the document, save the document by clicking the “file” from the menu bar and click ”save” .When we save the document for the first time  name is to be entered and click “save”
    Now the document has been created successfully.









EXERCISE 1:
To create your class time table.

.
                    (Approved by AICTE, New Delhi & Affiliated to Anna University)
Polachi-642 002
Department of Mechanical Engineering                                                Year/ Sem: I / I Branch: B.E MECH `B`                                  
                                                                                                                                                                    
     
Hour/ Day    1    2    3    4        5    6    7    8
    9.15-10.05    10.05-10.55    11.10-12.00    12.00-12.50        1.30-2.20    2.20-3.10    3.20-4.10    4.10-5.00
I    CHE    BEEE    PHY    MAT         BEEE    MAT    ENG    YOGA
II    EM    CHE    ENG    MAT        PHY    CPL/ CADD LAB NL-I
III    ENG    CPL/ CADD LAB NL-I        BEEE    CHE    EM    BEEE
IV    MAT    EM    MAT    EM        CHE    PHY    ENG
V    PHY    MAT    ENG    CHE        EM    BEEE    PHY    MAT
VI    BEEE    PHY    EM    MAT        CHE    PHY/ CHE LAB
       











Result:
Thus the above experiment has been created Successfully.


CREATE A MERGED DOCUMENT
AIM:
To create a merged document using Microsoft word.
PROCEDURE:
    To enter Microsoft word, Click “start” button then click “program” from “programs” menu then click “Microsoft word”
    Click “Tools” from the menu and choose “Letters and mailings”, then click “mail merge” from it.
     Then proceed with the following six steps to create a merged document.
1.    From the list of document types available choose “letters” 
2.    Select current document as the starting  document
3.    Then select the recipients from the list. If the list is already available choose “Use an existing list” otherwise choose “Type a new list” and type the names & addresses of recipients
4.    Write the content of the letter. To add recipient information to the letter, click a location in the document and then click “Address block”
5.    One of the merged letter will be previewed and to preview another letter click one of the following:
            <<Recipient: 1>>
6.     On clicking “complete the mail merge” mail merge is ready to produce the letters
    Now the document has been created successfully.






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

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


To


Dear,
Sub: Invitation for party.
    I hereby invite you and your family members for the 25th anniversary of my parents that is to be held on 28-11-2008 at our home. Please do come and share with us our joy. I will be disappointed in your absence.
   

                                Yours lovingly,
Result:
Thus the above experiment has been created Successfully.


FLOWCHART
AIM:
To create a flowchart using Microsoft word.
PROCEDURE:
    To enter Microsoft word, Click “start” button then click “program” from “programs” menu then click “Microsoft word”
    For opening a word document do the following. Click “file” menu from the menu bar. From this file menu click “new” option. This will display the new document.
    Enter the heading, change the font size. Click the “B” button on the formatting tool bar so that the heading appears bold.
    To change the font color click A button on the drawing tool bar and select the required colors.
    Click “Auto shapes” option from the drawing tool bar, then click “flowchart” and all the shapes will appear on the screen.
    Select the needed shapes one by one and place it on the screen. To connect all the boxes use flow lines from the drawing tool bar.
    To add text inside the shape, select the particular shape and right click the mouse button. Then a menu appears on the screen, select “add text” from the menu. Now the cursor appears inside the shape and allows us to enter the text.
    Now the flowchart has been created successfully.








Exercise 1:
Draw a flowchart to find the factorial of a given number using function.


FLOW CHART FOR ADDITION OF TWO NUMBER



                                                                                                   












Result:
Thus the above experiment has been created Successfully.



MS-EXCEL
     An electronic spreadsheet or spreadsheet is a table of rows and columns into which data is entered. Spreadsheet software makes it possible to enter data into a task format, manipulate, store, print and create reports and graphics using them.
    Microsoft Excel is the most widely used and versatile spreadsheet package and lets you to organize your data into lists and then summarize, compare and present the data graphically. It has the user interface features common to other Microsoft office applications.
MS-EXCEL allows you to
    Enter and edit data in a worksheet
    Use functions and formulae to calculate and analyze data
    Create colorful charts and graphs
    Save time by combining a series of commands into a single command by using MACROS













CHART CREATION
AIM:
To create a chart for the given data.
PROCEDURE:
    To enter Microsoft Excel, Click “start” button then click “program” from “programs” menu then click “Microsoft Excel”
    For opening a work book do the following. Click “file” menu from the menu bar. From this file menu click “new” option. This will display the new work sheet.
    Enter the data by placing the mouse pointer in a cell and a double click on it. Use the tab key to switch from one cell to another.
    To insert charts select the data to which the chart should be created. Now click insert chart icon. A window will appear and select the appropriate chart from it. Click next and enter the title, category(x) axis, category(y) axis etc. Click finish button.
    Then the appropriate chart is placed in the worksheet.














EXERCISE 1:
Using various Charts compare the performance of 3 students in their examination. Create Line, XY, Bar, Pie charts for the following data
NAME    MARK1    MARK2    MARK3
Anto    96    85    45
Ignatius    80    59    85
Griffin    78    89    45


Output:
    Line chart            Pie chart       
       

           

       
           
           
           
           
           
           
           
    Bar chart           



X-Y chart       


               
               

                               
                                   
                                   
                                   
                                   
                                   
                                   
                                   





Result:
Thus the above experiment has been created Successfully.

























FORMULA EDITOR
AIM:
    To calculate HRA, DA, TA, PF, GPF, LIC, Gross salary, Deductions, Net salary from the given data in a worksheet.
ENO    Name    Basic    HRA    TA    DA    LIC    PF    GPF    GS    DED    NET
1    Abc    20000                                   
2    Asd    15000                                   
3    Bfr    10000                                   
4    Cde    7820                                   
5    Erg    4569                                   
Where
HRA is 18% of basic
DA is 15% of basic
TA is 12% of basic
PF is 10% of basic
GPF is 5% of basic
LIC is 7% of basic
GS (Gross salary) =Basis+HRA+DA+TA
DED (Deduction) =PF+GPF+LIC
NET (Net salary) =GS-DED
PROCEDURE:
    To enter Microsoft Excel, Click “start” button then click “program” from “programs” menu then click “Microsoft Excel”
    For opening a word document do the following. Click “file” menu from the menu bar. From this file menu click “new” option. This will display the new work sheet.
    Enter the data by placing the mouse pointer in a cell and a double click on it. Use the tab key to switch from one cell to another.
    For putting formulas, for eg,place the cursor on a cell which you have to calculate the value of HRA, then type
=cell position of basic*18% and press enter.
Now the value of HRA is calculated. Similarly do for all others.
    Calculate the same for other columns and drag them to all the cells.
    Now the entire table is ready in spreadsheet.
Output:


Result:
Thus the above experiment has been created Successfully.




SPREAD SHEET-INCLUSION OF OBJECT, PICTURE & GRAPHICS, PROTECTING THE DOCUMENT
AIM:
i.    Insert object in the worksheet
ii.    Insert picture in the worksheet
iii.    Protect a sheet
PROCEDURE:
    To enter Microsoft Excel, Click “start” button then click “program” from “programs” menu then click “Microsoft Excel”
    For opening a work sheet do the following. Click “file” menu from the menu bar. From this file menu click “new” option. This will display the new work sheet.
    For inserting object in the worksheet, choose objects option in the insert menu
    For inserting picture in the worksheet, choose Picture option in the insert menu
    For protecting your worksheet, choose Protection option from Tools menu, then choose Protect Sheet option, Protect sheet dialog box appears. Type a password and press enter.
    Now your worksheet is protected and can be entered only with the password.
Output:

Result:
Thus the above experiment has been created Successfully.



SORTING AND IMPORT/EXPORT FEATURES
AIM:
i.    Sort the given data in the worksheet
ii.    Include Import/export features
PROCEDURE:
    To enter Microsoft Excel, Click “start” button then click “program” from “programs” menu then click “Microsoft Excel”
    For opening a word document do the following. Click “file” menu from the menu bar. From this file menu click “new” option. This will display the new work sheet.
    Select the data to be sorted and select data from the menu and click sort
    Specify the order in which the data are to be sorted (ascending or descending) and click OK. Then the sorted data appears in the sheet.
    To import a file select Insert->object->create from file
    To export a file while saving the file save it as webpage so that it can be viewed by internet explorer
EXERCISE 1:
Sort the given data in ascending and descending order (consider the name).
NAME    MARK1    MARK2    MARK3
Anto    96    85    45
Ignatius    80    59    85
Griffin    78    89    45


EXERCISE 2:
Sort the  list of 10 students according to their average where Average=M1+M2+M3+M4+M5








Result:
Thus the above experiment has been created Successfully.




SIMPLE PROGRAMS
1. TEMPERATURE CONVERSION
AIM:
To write a C program to convert the Celsius into Fahrenheit.
Formula:
FAHRENHEIT= CELSIUS*1.8 +32
ALGORITHM:
Step 1: Enter the CELSIUS value.
Step 2: Calculate the FAHRENHEIT value by multiplying CELSIUS with  1.8 and add 32 
Step 3: Print the FAHRENHEIT value.
Program:
#include<stdio.h>
#include<conio.h>
main()
{
float cel,faren;
clrscr();
printf(“Enter the Celsius Value…”);
scanf(“%f”,&cel);
faren=(1.8*cel)+32;
printf(“The Fahrenheit value of given %f Celsius Value is %f”,cel,faren);
getch();
return 0;
}
Output:
Enter the Celsius Value
23
The Fahrenheit value of given 23.000000 Celsius Value is 73.400002

Result:
Thus the above experiment has been executed and output was verified Successfully.

2. SIMPLE INTEREST CALCULATION
AIM:
To write a C program to calculate the simple interest.
Formula:
Simple Interest = (P*N*R)/100
ALGORITHM:
Step 1: Read the principal amount P, interest rate R and period N.
Step 2: Calculate Simple Interest by multiplying principal amount P, interest Rate R, period N and         dividing by 100.
Step 3: Print the value of Simple Interest.
Program: 
#include<stdio.h>
#include<conio.h>
void main()
{
float p,r,n,si;
clrscr();
printf("\nEnter the profit, rate & no of yr\n\n ");
scanf("f%f",&p,&r,&n);
si=(p*r*n)/100;
printf("\nSimple Interest=%f",si);
getch();
}

Output:
Enter the profit, rate & no of yr
 5000 2 5
Simple Interest=500.000000

Result:
Thus the above experiment has been executed and output was verified Successfully.


3. SWAP USING TWO VARIABLES
AIM:
To write a C program to perform swapping using two variables.
ALGORITHM:
Step 1: Read the two numbers a & b
Step 2:  Perform
    2.1 a = a + b;
    2.2 b = a - b;
    2.3 a = a - b;
Step 3: Print the numbers a and b
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int x,y;
clrscr();
printf(“\n\nEnter the two numbers…”);
scanf(“%d%d”,&x,&y);
printf(“\n\nThe entered number for x and y are x=%d\ty=%d”,x,y);
display(&x,&y);
printf(“\n\nAfter the swapping the value of  x=%d\ty=%d”,x,y);
getch();
display(int *a,int *b)
{
int t;
t=*a;
*a=*b;
*b=t;
}







Output:
Enter the two numbers…33 8
The entered number for x and y are  x=33    y=8
After the swapping the value of   x=8        y=33

















Result:
Thus the above experiment has been executed and output was verified Successfully.




CONDITIONAL STATEMENTS
4. ROOTS OF A QUADRATIC EQUATION
AIM:
To write a  C program to find the roots of the Quadratic Equation.
Formula:
D=B2-4AC
Condition 1: D= =0
ROOT1=ROOT2= (-B+ √D)/ (2*A)
Condition 2: D>0
ROOT1= (-B+√D)/ (2*A)
ROOT2= (-B-√D)/ (2*A)
Condition 3: D<0
X = (-B) / (2 * A)
Y=√-D/ (2*A)
 Print them in the format of (X + iY), (X – iY)
ALGORITHM:
Step 1: Enter the value of A, B, C
Step 2: Find the value of D by using the formula D = (B*B) – (4*A*C)
Step 3: If D is equal to zero then
            3.1 Print Roots are real and equal
            3:2 Find the two roots as ROOT1 = (-B + SQRT ((D)) / (2*A)
      3.3 Print the ROOT1 two times.
Step 4: If D is greater than zero then
    4.1 Print Roots are real and unequal
    4.2 Find the two roots as
        ROOT1 = (-B + SQRT ((D)) / (2 * A)
        ROOT2 = (-B – SQRT ((D)) / (2 * A)
    4.3 Print ROOT1 and ROOT2
Step 5: If D is less than zero then
    5.1 Print the Roots are imaginary
    5.2 Find the two roots as
        X = (-B) / (2 * A)
        Y=√-D/ (2*A)
    5.3 Print them in the format of (X + iY), (X – iY)

Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d;
float r1,r2,e;
clrscr();
printf(“\n Enter the values of quadratic equation”);
scanf(“%d%d%d”,&a,&b,&c);
d=b*b-4*a*c;
if(d<0)
printf(“\n Roots are Imaginary”);
else
{
if(d==0)
{
e=-b/2*a;
printf(“\n %f”,e);
}
else
{
r1=(-b+sqrt(d))/2*a;
r2=(-b-sqrt(d))/2*a;
printf(“\n %f,%f are the roots”,r1,r2);
}
}
getch();
}

Output:
 Enter the values of quadratic equation

4 2 5

Roots are Imaginary

 Enter the values of quadratic equation

2 -6 3

 9.464102, 2.535898 are the roots

Result:
Thus the above experiment has been executed and output was verified Successfully.



5. ELECTRICITY BILL PREPARATION
AIM
To write a C program to prepare the electricity bill.
An electric power distribution company charges its domestic consumers as follows:
CONSUMPTION UNITS    RATE OF CHARGE
<=100    Rs.0.50 per unit
101-200    Rs 100+ Rs. 0.65 per unit excess of 200
201-400    Rs 230+ Rs. 0.80 per unit excess of 400
401 and above    Rs 390+ Rs. 1 per unit excess of 600
ALGORITHM:
Step 1: Enter the value units
Step 2: If units are in the range 0-100
    Charges=0.50*units           
Step 3:  If units are in the range 101-200
     Charges=100 + 0.65*units        
Step 4:  If units are in the range 201-400
     Charges=230 + 0.80*units
Step 5:  If units are in the range 401 and above
     Charges=390 + 1*units
Step 6: Print the charges





Program:
#include<stdio.h>
#include<math.h>
main()
{
int units;
float bill;
printf("Enter number of units consumed:");
scanf("%d", &units);
if (units<=100)
bill = 0.50 * units;
else
{
if (units<=200)
bill = 0.50 * 100 + 0.65 * (units-100);
else
{
if (units<=400)
bill = 0.50 * 100 + 0.65 * 100 + 0.80 * (units -200);
else
{
if (units>400)
bill = 0.50 * 100 + 0.65 * 100 + 0.80 * 200+1*(units-400);
}
}
}
printf("Your bill is = %5.2f",bill);
}


Output:
Enter number of units consumed:347
Your bill is = 232.60





Result:
Thus the above experiment has been executed and output was verified Successfully.

6. REVERSING THE GIVEN NUMBER
AIM:
To write a C program to reverse the given integer using while loop.
ALGORITHM:
Step 1: Initialize SUM as 0
Step 2: Enter the number, N to be reversed
Step 3: While the number, N is not less than zero do
    3.1 R = Find the remainder of N divided by 10
    3.2 SUM = Multiply SUM by 10 and add to R
    3.3 N = Find the Quotient of N divided by 10
Step 4: Print the value of SUM, which is the reversal of a given number.
Program:
#include<stdio.h>
#include<conio.h>
long int reverse(long int);
void main()
{
 long int n;
 clrscr();
 printf("enter the value \n");
 scanf("%ld",&n);
 printf("result=%ld",reverse(n));
 getch();
 }
long int reverse(long int a)
{
 int r;
 long int s=0;
 while (a != 0)
 {
  r=a%10;
  s=10*(s+r);
  a=a/10;
  reverse(a);
  }
 return (s/10);
 }


Output:
enter the value
12345
result=54321

















Result:
Thus the above experiment has been executed and output was verified Successfully.



7. ARMSTRONG NUMBER GENERATION
AIM
To write a C program to generate Armstrong numbers using do while loop.
ALGORITHM
Step 1: Get limit of the generation N
Step 2: Do the following for N times
           Step 2.1: SUM = sum of cubes of each digit of original number
           Step 2.2: If original number and SUM is same, then print the original Number.
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,n,b=0,t;
clrscr();
printf(“Enter the no”);
scanf(“%d”,&n);
t=n;
while(n>0)
{
a=n%10;
b=b+a*a*a;
n=n/10;
}
if(b==t)
{
printf(“Armstrong no”);
}
else
{
printf(“Not an Armstrong no”);
}
getch();
}






Output:
Enter the no
5
Not an Armstrong no

Enter the no
1
Armstrong no















Result:
Thus the above experiment has been executed and output was verified Successfully.

ARRAYS
8. SORTING THE GIVEN ARRAY OF NUMBERS
AIM
To write a  C program to sort the given array of numbers in ascending / descending.
ALGORITHM
Step 1: Enter the size of the array N.
Step 2: Enter the elements of the array A.
Step 3: Set an outer loop up to N-1
Step 3.1: Set an inner loop up to N-1
Step 3.2: If first number is greater than next number, then swap them
Step 4: Print the ascending order of the given array (from 0th element to nth   element).
Step 5: Print the descending order of the given array (from nth element to 0th element ).
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[10],i,n,j,t;
clrscr();
printf(“enter size of array: “);
scanf(“%d”,&n);
printf(” enter array elements: “);
for(i=0;i<n;i++)
{
scanf(“%d”,&a[i]);
}
printf(” array before sorting\n”);
for(i=0;i<n;i++)
{
printf(“%d\n”,a[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(a[i]>a[j])
{
t=a[i];
a[i]=a[j];
a[j]=t;
}
}
}
printf(“\n after sorting\n”);
for(i=0;i<n;i++)
{
printf(“%d\n”,a[i]);
}
getch();
}
Output:
enter size of array:5
 enter array elements: 3 7 1 9 2
array before sorting
3
7
1
9
2
 after sorting
1
2
3
7
9


Result:
Thus the above experiment has been executed and output was verified Successfully.


9. MATRIX MULTIPLICATION
AIM
To write a  C program to multiply two matrices.
ALORITHM
Step1: Enter the row and column value
Step2: Enter the elements of the matrix A.
Step 3: Enter the elements of the matrix B.
Step 4: Print the matrix A in the matrix form.
Step 5: Print the matrix B in the matrix form.
Step 6: Set a loop up for row values (i)
Step 6.1: Set an inner loop up for column values (j).
Step 6.2: Set one more inner loop (k)
Step 6.3: Perform C[i] [j] = C[i] [j] + A[i] [k] * B[k] [j]
Perform the above for the various values of i, j and k
Step 7: Print matrix C.
Program:
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j,k,n,m,a;
clrscr();
printf(“Enter the no.of rows in the matrix:“);
scanf(“%d”,&n);
printf(“Enter the no.of column in the matrix:“);
scanf(“%d”,&m);
printf(“\nEnter the values in the matrix A:\n”);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf(“%d”,&a[i][j]);
}
}
printf(“\nEnter the values in the matrix B:\n “);
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
scanf(“%d”,&b[i][j]);
}
}
for(i=0;i<n;i++)
{
for(j=0;j<m;j++)
{
c[i][j]=0;
for(k=0;k<n;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
printf(“\nThe multiplication  of  two  matrix is:\n\n“);
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
printf(“%d “ ,c[i][j]);
printf(“\t”)
}
printf(“\n”);
}
getch();
}

Output:
Enter the no.of rows in the matrix: 2
Enter the no.of column in the matrix: 2
Enter the values in the matrix A:

2    2
2    2

Enter the values in the matrix B:

2    2
2    2
The multiplication  of  two  matrix is:


8    8
8    8























Result:        
         Thus the above experiment has been executed and output was verified Successfully.


STRUCTURES & UNIONS
10. STUDENT’S MARKS CALCULATION USING STRUCTURE
AIM
To write a  C program to prepare students mark list using structure.
ALGORITHM
Step1: Define the STUDENTS structure with details of Roll no, Name, Marks
Step2: Get the number of students as N.
Step3: Declare a structure variable with size N.
Step4: Do the following for N times
Step4.1: Get the details of the student.
Step4.2: Calculate total, average, and Grade
Step4.3: Print the student’s individual Mark list with total, average and Grade.

Program:
#include<stdio.h>
#include<conio.h>
#include<string.h>
struct student
{
char name[20];
int number,m1,m2,m3,total;
float avg;
};
void main()
{
struct student s1;
clrscr();
printf(“\n\t\tSTUDENT REPORT USIN STRUCTURES\n”);
printf(“\n Enter the student name:..”);
scanf(“%s”,&s1.name);
printf(“\n Enter the Roll Number of the student:..”);
scanf(“%d”,&s1.number);
printf(“\n Enter the Three marks of the student:..”);
scanf(“%d%d%d”,&s1.m1,&s1.m2,&s1.m3);
s1.total=s1.m1+s1.m2+s1.m3;
s1.avg=s1.total/3;
printf(“\n Roll Number=%d”,s1.number);
printf(“\n Name=%s”,s1.name);
printf(“\n Total=%d \n Average=%f”,s1.total,s1.avg);
getch();
}




Output:
                STUDENT REPORT USIN STRUCTURES
 Enter the student name:..Swetha
 Enter the Roll Number of the student:..3
 Enter the Three marks of the student:..97
99
100

 Roll Number=3
 Name=Swetha
 Total=296
 Average=98.000000










Result:
Thus the above experiment has been executed and output was verified Successfully.



11. EMPLOYEE DETAILS USING STRUCTURE
AIM
To write a  C program to prepare Employee pay slip using Structure.
ALGORITHM
Step1: Define the EMP structure with details of employee number, Name, Basic pay.                                              
Step2: Get the number of employees as N
Step3: Declare a structure variable with size N.
Step4: Do the following for N times
Step4.1: Get the details for an employees
Step4.2: Calculate Net Salary, Deduction and Gross Salary.
Step4.3: Print the employees pay slip with Net Salary, Deduction and  Gross Salary.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
union emp
{
char name[25],design[20];
int salary;
}e[5];
int i,no;
clrscr();
printf("Enter the no.of employee:");
scanf("%d",&no);
for(i=0;i<no;i++)
{
printf("\nEmployee[%d] information:\n",i+1);
printf("Enter the name:");
scanf("%s",e[i].name);
printf("Enter the designation:");
scanf("%s",e[i].design);
printf("Enter the salary:");
scanf("%s",&e[i].salary);
}
getch();
}



Output:

Enter the no.of employee:2

Employee[1] information:
Enter the name:Dhanam
Enter the designation:Professor
Enter the salary:30000

Employee[2] information:
Enter the name:Amudha
Enter the designation:Assit.Prof
Enter the salary:25000

















Result:
Thus the above experiment has been executed and output was verified Successfully.



FUNCTIONS & RECURSION
12. MENU DRIVEN CALCULATOR USING FUNCTIONS
AIM:
 To write a  C program to perform the arithmetic operations using functions
ALGORITHM:
Step 1: Get the values A and B
Step 2: Display the choices and also get the option
Step 3: If OPTION IS 1, call function ADD (A, B) and assign the result in D.
Step 4: If OPTION IS 2, call function SUB (A, B) and assign the result in D.
Step 5: If OPTION IS 3, call function MUL (A, B) and assign the result in D.
Step 6: If OPTION IS 4, call function DIV (A, B) and assign the result in D.
Step 7: Call function DISPLAY (D)

ALGORITHM FOR ADD (A, B):

Step 1: Add the values of A and B and assign the result in G
Step 2: Return the variable, G.
ALGORITHM FOR SUB (A, B):

Step 1: Subtract B from  A and assign the result in G
Step 2: Return the variable, G.

ALGORITHM FOR MUL (A, B):

Step 1: Multiply A and B and assign the result in G
Step 2: Return the variable, G.

ALGORITHM FOR DIV (A, B):

Step 1: Divide A by B and assign the result in G
Step 2: Return the variable, G.

ALGORITHM FOR DISPLAY (D):
Step 1: Display the value of D.








Program:
#include<stdio.h>
#include<math.h>
void main()
{
int a,b,c,ch;
clrscr();
printf(“Arithmetic Operations using Menus\n”);
printf(“Enter the two values for calculation::”);
scanf(“%d %d”,&a,&b);
printf(“\n\t\tMENU\n “);
printf(“\n Enter the Choice of Operation \n 1.Add\n2.Sub\n3.Multiply\n4.Division\n5.Remainder\n\n”);
scanf(“%d”,&ch);
switch(ch)
{
case 1:c=a+b;
 break;
case 2:c=a-b;
 break;
case 3:c=a*b;
 break;
case 4:c=a/b;
 break;
case 5:c=a%b;
 break;
default: exit(0);
}
printf(“Result=%d”,c);
getch();
}











Output:
Arithmetic Operations using Menus
Enter the two values for calculation::34 98
                MENU
 Enter the Choice of Operation
 1.Add
2.Sub
3.Multiply
4.Division
5.Remainder
5
Result=34










Result:
Thus the above experiment has been executed and output was verified Successfully.


13. FIBONNACI SERIES
AIM:
To write a C program using recursion generate the Fibonacci series up to for the given number.
Series:
 0  1  1  2  3  5  8  13
ALGORITHM:
Step 1: Enter the number N.
Step 2: Initialise f=-1 and s=1
Step 3: Call the recursive function FIBO, with N, f and s as arguments.
 ALGORITHM FOR FIBO (N,f,s):
Step 1: If N is greater than Zero
1.1    no=f+s
1.2    print the no
1.3    Call the recursive function FIBO, with N-1, s and no as arguments.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int num,fib=0,a=0,b=1,i;
clrscr();
printf(“Enter the number:”);
scanf(“%d”,&num);
printf(“\n Fibonacci series\n” );
if(num==0)
printf("0");
else
{
for(i=0;i<num;i++)
{
fib=fib+a;
a=b;
b=fib;
printf(“%d\n\n”,fb);
}


}
getch();
}


Output:
Enter the number 8
Fibonacci series
0
1
1
2
3
5
8
13













Result:
Thus the above experiment has been executed and output was verified Successfully.

14. FACTORIAL
AIM:
To write a C program using recursion to find the factorial of the given number.
ALGORITHM:
Step 1: Enter the number N.
Step 2: Call the recursive function FACT, with N as an argument.
Step 3: Print the returned value of a function FACT
ALGORITHM FOR FACT (K):
Step 1: If the number K is equal to 1, then return 1
Step 2: Otherwise call it recursively with N-1 as an argument and return it.
Program:
#include<stdio.h>
#include<conio.h>
void main()
{
int fact=1,i,num;
clrscr();
printf(“Enter the Number”);
scanf(“%d”,&num);
for(i=1;i<=num;i++)
{
fact=fact*i;
}
printf(“The factorial is %d”,fact);
getch();
}
Output:
Enter the Number 7
The factorial is 5040
Result:    
Thus the above experiment has been executed and output was verified Successfully

No comments:

Post a Comment