ge6161 computer practices laboratory l t p c … · ge6161 computer practices laboratory l t p c 0...
TRANSCRIPT
GE6161 COMPUTER PRACTICES LABORATORY L T P C 0 0 3 2
1. Search, generate, manipulate data using MS office/ Open Office
2. Presentation and Visualization – graphs, charts, 2D, 3D
3. Problem formulation, Problem Solving and Flowcharts
4. C Programming using Simple statements and expressions
5. Scientific problem solving using decision making and looping.
6. Simple programming for one dimensional and two dimensional arrays.
7. Solving problems using String functions
8. Programs with user defined functions – Includes Parameter Passing
9. Program using Recursive Function and conversion from given program to flow chart.
10. Program using structures and unions.
TOTAL : 45 PERIODS
TABLE OF CONTENTS
Ex. No Exp. Date Name of the experiment Sub. Date
MICROSOFT WORD
1a BROCHURE DESIGN
1b TIME TABLE
1c EQUATION
1d MAIL MERGE
1e FLOW CHART
MICROSOFT EXCEL
2a CHART CREATION
2b SUBJECT GRADE
2c EMPLOYEE PAYROLL
2d ELECTRICITY BILL
MICROSOFT POWERPOINT
3a MY INSTITUTION
C PROGRAMMING
4a CIRCLE AREA
4b QUADRATIC EQUATION
5a LEAP YEAR
5b SIMPLE CALCULATOR
5c BINARY TO DECIMAL
5d PRIME NUMBER
6a ARRAY MINIMUM / MAXIMUM
6b MATRIX MULTIPLICATION
7a PALINDROME
7b ALPHABETICAL ORDER
8a SINE SERIES
8b PASS BY VALUE & REFERENCE
9a FACTORIAL RECURSION
9b FIBONACCI RECURSION
10a PAY ROLL APPLICATION
10b UNION USAGE
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.1
Ex. No. 1a BROCHURE DESIGN
AimTo design brochure for a national conference using formatting options.
Procedure
1. Click Orientation Landscape in Page Layout tab to have a wide layout.
2. Click Narrow Margins in Page Layout tab to have most of page space for text.
3. Click Columns Three in Page Layout tab to have a three column document
4. Click Page Borders in Page Layout tab to have page borders.a) Select Box setting and a border style in Page Border tab.
5. In the first column type conference title, insert logo and sponsors, etc.6. To have names in stylish format, click Word Art in Insert tab.
a) Choose the desired style and type the text in the Edit dialog.7. To insert picture & clip art, click Picture/Clip Art in Insert tab.
a) Browse in default or other folder and select the desired picture/clip art.8. Type text, topics, registration, members and other information in 2nd and 3rd column.
9. Click on Bullet/List icon in Home tab to highlight concise text.
10. To convert text to hyperlink, select the text and click Hyperlink in Insert tab.a) Type URL in the Address space and click OK.b) For email address, select E-mail Address in Link to palette and type mail
address in the Address space.11. Manipulate text with alignment options (left/right/center/justify), formatting options
(bold/underline/italic), spacing, etc.12. Save the file and see print preview by clicking office button.
Result
Thus a conference brochure was designed neatly using MS-Word.
OMR, Thaiyur Village, Kelambakkam–603103
NATIONAL CONFERENCE
ON
COMPUTER COMMUNICATION & NETWORKING
20TH MARCH 2009
Organized byDept. of CSE, IT & MCA
Supported by
OBJECTIVEThe main objective of this conference is to bringexperts in engineering and technology,academicians, professional engineers, researchscholars, consultants and industrialists on acommon platform to exchange ideas relating torecent development and trends in computercommunication and networking fields.
SCOPEThe broad topics include but not limited to:
Grid ComputingSoft ComputingPervasive ComputingDistributed ComputingNetwork SecurityArtificial IntelligenceCloud ComputingWireless Communication
INSTRUCTIONSAuthors intending to submit a paper should mailtheir full paper not exceeding 8 pages by Feb 20,2009 to [email protected]. Paper must beprepared in IEEE format as word document. Thepaper submitted must be an original contributionand must not have been published or presentedelsewhere earlier. Submitted papers will beassessed by two reviewers. Reviews / suggestions/ corrections are binding on authors. For acceptedpapers, at least one of the authors must presentthe paper for it to appear in the conferenceproceedings.
IMPORTANT DATES
Last date for submission : 20th Feb. 2009Acceptance notification : 25th Feb. 2009Camera ready paper : 4th Mar. 2009Registration deadline : 18th Mar. 2009
REGISTRATION FEE
Students & Research Scholars : Rs. 300/-Academicians : Rs. 500/-Industry delegates : Rs. 1000/-
The registration fee should be paid in the form ofDemand Draft drawn in favor of “The Principal,SMK Fomra Institute of Technology” payableat Chennai.
CONFERENCE COMMITTEE
Chief PatronsShri Sundarlal Fomra, Chairman, SMKFITShri Natwarlal Fomra, Trustee, SMKFITPatronsDr. L. Mahesh Kumar, Principal, SMKFITAdvisory CommitteeDr. S. Salivahanan, Principal, SSNCEDr. V. Vaidehi, Professor, MIT, Anna UniversityConvenerDr. B. Chandramouli, Prof. & Head, Dept of ITOrganizing SecretaryMr. R. Ramesh, Head, Dept of CSEOrganizing CommitteeProf. Sridhar Ranganathan, Prof., CSEMs. M. Bharathi, Prof. & Head, MCADr. T.M. Sridhar, Prof. & Head, BMEMs. S. Chandravadhana, Head, ECE
ADDRESS FOR CORRESPONDENCEThe Organizing Secretary,NCCCN ‘09,S.M.K. Fomra Institute of Technology,Kelambakkam–603 103.Ph: 044-27475621/22E-mail: [email protected]: www.smkfomra.net/
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.2
Ex. No. 1b TIME TABLE
Aim
To create a well formatted class time table.
Procedure
1. Type table caption and center it.2. Click Table Insert Table in Insert tab.
a) Specify Number of columns as 11 and Number of rows as 6.b) An empty table with rows and columns specified is created.
3. If adjacent periods are the same, then select the periods and click Merge Cells inLayout tab.
4. For Break and Lunch merge the entire column.a) Click Shading in Design tab and choose a color.
5. Format the first row and first column as bold.
6. Select the table and click Layout tab.a) Click Align Center toolbar button.b) Specify Height, say 0.6 (same for all the rows).
7. Enter subject code for the respective periods.
8. Similarly create another table with three columns and enter the subject code, title andstaff respectively.
9. To insert a row/column, click Layout tab and select Insert Above/Insert Below forrow or Insert Left/Insert Right for column.
10. To delete a row/column/table click Layout tab and select Delete DeleteRows/Delete Columns/Delete Table.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.3
Output
I BME Time Table
1
8:15 AM –9:05 AM
2
09:05AM –09:55 AM
BREAK
3
10:05 AM –10:55 AM
4
10:55 AM –11:45 AM
LUNCH
5
11:45 AM –12:25 PM
6
1:05 PM –1:50 PM
7
1:50 PM –2:35 PM
8
2:35 PM –3:20 PM
MON MA6151 CY6151 GE6151 PH6151 MA6151 GE6161
TUE PH6151 GE6151 HS6151 MA6151 HS6151 PH6151 MA6151
WED CY6151 GE6162 GE6162 PH6151 HS6151 GE6151 CY6151
THU HS6151 GE6163 GE6163 CY6151 HS6151 GE6152
FRI GE6151 PH6151 CY6151 MA6151 GE6151 GE6152
Subject Code Course Title Staff Name
HS6151 Technical English - I Dr. Baburajan
MA6151 Mathematics - I Ms. Elavarasi
PH6151 Engineering Physics - I Dr. M. Prabu
CY6151 Engineering Chemistry - I Ms. ShaliniAnbazhagan
GE6151 Computer Programming Mrs. Jeyalaximi
GE6152 Engineering Graphics Mr.Vijaybaskar
GE6161 Computer Practices LaboratoryMr. Senthil Kumar/Mr. S.K. VijaiAnand/Ms. Jeyanthi
GE6162 Engineering Practices LaboratoryMr.Vijaybaskar/Mr. Manoj Kumar
GE6163 Physics and Chemistry Laboratory - IMs.Sandhya/Mr. C. Saravanan
Result
Thus class time table was created using table options.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.4
Ex. No. 1c EQUATION
Aim
To type mathematical, chemical or any type of equation in MS-Word.
Procedure
1. For equations that consist of keyboard characters.a) Type the equation text.b) For subscripted text, select the text and click subscript icon X2.c) For superscripted text, select the text and click subscript icon X2.
2. For equations that consist of simple symbols, i.e., non-keyboard characters that haveneither subscript nor superscript:
a) Click Symbol in Insert tab and select the symbol.b) If symbol is not available, then click More Symbols and choose the symbol in
the Symbol dialog.3. For well-known equation click Equation in Insert tab and choose the built-in
equation.
4. To create a new equation click on Equation Insert New Equation in Insert tab.a) A new equation holder appears.b) Choose a subtype in Structures collection that resembles the given equation in
Design tab and edit it.c) Relevant structure type for a sub-expression can be chosen and edited.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.5
Output
(a1+ a2)2 =a12 + 2a1a2+a2
2
C6H12O6+6O2 6CO2+6H2O
Result
Thus complex equations were entered without the need for any third party software.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.6
Ex. No. 1d MAIL MERGE
AimTo report parents about student performance using mail merge.
Algorithm1. Click Header Blank in Insert tab and design letter head in the header part by
inserting logo, college name and other details.2. Draft a letter that reports to parents about their son/daughter performance.
a) Click Date & Time in Insert tab and choose a date format to insert date.b) The sender should be class in-charge and leave the recipient blank.c) Information such as student name, register no., marks, attendance is left
blank.
3. Click Footer Blank in Insert tab and design footer that includes contact detailsafter a line.
4. To add watermark as page background,a) Click Watermark Custom Watermark in Design tab.b) Choose Picture watermark or Text watermark and specify the
filename/text.
5. Click Start Mail Merge Letter in Mailings tab.
6. Click Select Recipients Type New List in Mailings tab.a) Click Customize Columns to modify the default database.b) The fields should be ordered as Register No, Student name, Theory subject
codes, Attendance, Parent name, Address, Area, City and Zip code.c) Enter data sets, click OK and save the database.
7. Place cursor below the To line and click Address Block in Mailings tab.a) If preview shown in Insert Address dialog is correct then click OK.b) Otherwise click Match Fields and choose the missing fields in drop down
list.
8. Click Insert Merge Field required field to insert fields such as subject marks,student name, register no., attendance at relevant position.
9. Click Preview Results in Mailings tab to view database merged with letter.10. Click Finish & Merge Print Documents in Mailings tab to complete the process.
11. To print address as labels:a) In a new document, click Start Mail Merge Labels in Mailings tab.b) Choose Compulabel for Label vendors and 311207-Address label for
Product number in Label Options dialog window.c) Insert recipient address as in step7.d) Click Update labels in Mailings tab.e) Preview and print the labels.
ResultThus the Mail Merge and Letter Preparation is created using Microsoft word and
output is executed successfully.
SHREE MOTILAL KANHAIYALAL FOMRAINSTITUTE OF TECHNOLOGY
(An NBA Accredited and ISO 9001-2000 Certified Institution)www.smkfomra.net
Old Mahabalipuram Road, Thaiyur Village, Kelambakkam–603103, : 27475621/22.
Date:7-Nov-13FromThe Class Coordinator,[I Year BME],SMKFIT.
To«AddressBlock»
Sub: Internal Assessment-I Performance – Reg.
This is to inform you that «Student_Name» (Reg. No: «RegisterNo») has scored the
following marks in Internal Examination-I and his attendance as given below:
Subject Name Marks(100)
Technical English – I «HS6151»
Mathematics – I «MA6151»
Engineering Physics – I «PH6151»
Engineering Chemistry – I «CY6151»
Computer Programming «GE6151»
Engineering Graphics «GE6152»
Attendance (in %) «Attendance»
It is mandatory for parents to come and meet the class coordinator on 16-Nov-2013
without fail.
Yours truly,
(Class Coordinator)
«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
«Next Record»«AddressBlock» «Next Record»«AddressBlock» «Next Record»«AddressBlock»
RegisterNoStudent Name HS6151 MA6151 PH6151 CY6151 GE6151 GE6152 AttendanceParent Name Address Area City ZIP Code4108 Hansika 56 67 78 56 67 69 84 Dhanraj No. 18, Flower Saidapet Chennai 6000154013 Rajesh 45 56 67 56 71 60 78 Ganesh 22, III Cross Str Butt Road Chennai 6000164040 Hariharan 56 67 78 60 64 66 87 Logesh Kumar #15, LB Road Adyar Chennai 6000254026 Gopal 78 89 87 67 65 78 85 Rajendran No. 15, TVK Ma Guindy Chennai 6000324103 Vanitha 12 23 34 45 56 43 45 Indira No. 24, E Block, Pudhupakkam Kelambakkam 603103
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.7
Ex. No. 1e FLOW CHART
Aim
To draw flowchart for the given problem statement.
Procedure
1. For the given problem, have an algorithm in mind.
2. Click Shapes Flowchart required symbol in Insert tab and place it centered.Manipulate the length and height as desired.
3. The common flowchart symbols are given below:
Start / Terminate
Input / Output
Process
Loop (used in for loop)
Flow Lines
Decision
Connector
4. Right click on flowchart symbol and select Add Text to type text into the symbol.5. Connect the symbols using Flow lines.
6. To add any text (such as Yes/No) adjacent to symbols,a) Select the symbol and click Draw Text Box in Format Tab.b) Select the text box and click Shape Outline No Outline in Format Tab to
remove borders of the text box.
7. After finishing the entire flowchart select all the flowchart symbols and arrows, rightclick and click Grouping.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
W.8
Output
Result
Thus visual representation of problem statement is done using flowchart symbols.
N
Y
Read n
rev = 0
n > 0?
d = n % 10rev = rev * 10 + dn = n / 10
Print rev
Start
Stop
Flow Chart for Reversing Digits of any given number.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.1
Exp. No. 2a CHART CREATION
Aim
To create column/line/pie chart for the given set of data.
Procedure
1. Enter data in the Worksheet including header2. Select cells and choose chart type (Column/Line/Pie etc) in Insert tab.
3. Chart for the data appears.4. In Layout tab, configure the following:
a. Click Chart Title Above Chart and enter title for the chart.b. Click Axis Titles Primary Horizontal Axis Title Title Below Axis to enter X-axis
title (for Column/Line chart).c. Click Axis Titles Primary Vertical Axis Title Vertical Title to enter Y-axis title (for
Column/Line chart).d. Click Data Labels Outside End to display data on the chart (for Column chart).e. Click Gridlines Primary Horizontal Gridlines None to remove horizontal lines
from the chart (for Column/Line chart).
5. In Design Tab, click Switch Row/Column to change x-axis data for column chart.6. For Line Chart:
a. Right click on Y-axis scale and select Format Axis. In Format Axis dialog, specifythe minimum and maximum data.
b. Right click on X-axis and choose Select Data. In Select Data Source dialog, clickEdit and specify data values for X-axis.
c. Select a series, and click Data Labels Left for one and Data Labels Right for theother and so on.
7. For Pie Chart:a. Click Data Labels More Data Label Options and check option Percentage and
uncheck Values.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.2
Output
Computer Practice Aggregate (in %)Department Assess-1 Assess-2 Assess-3EEE 56 67 78ECE 73 45 81CIVIL 65 59 71CSE 89 74 50MECH 75 67 54
Ind vs AusOvers India Australia
5 45 2910 79 6215 97 8020 110 10025 125 11530 155 14035 175 16540 210 20045 240 230 50 295 275
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.3
First Quarter SalesProduct Sales (in Crores)
Printers 234Scanner 90Fax 109MFNs 150Desktops 300Laptops 270Servers 100Accessories 450
Result
The respective charts were created for visual inference of data
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.4
Exp. No. 2b SUBJECT GRADE
Aim
To determine grade obtained by the student in a semester examination.
Procedure
1. Select the cells in which internal marks are to be entered and click ConditionalFormatting Highlight Cells Rules Less Than… in Home tab
a) Specify 50 as value with Red Text formatting.
2. Select the cells in which internal marks are to be entered and click Data Validation DataValidation in Data tab
a) Choose Allow: Whole number, set Minimum to 0 and Maximum to 100,b) Choose Error alert style to Stop.
3. Enter the subject code and their internal assessment marks.4. Compute average by clicking AutoSum Average in Home tab.
5. Covert average (Cell E3) to 15 marks by clicking Math & Trig ROUND in Formulas tab.a) Type E3*0.15 in Numberb) Type 0 in Num_digits
6. Enter attendance marks in the range (0 – 5) using data validation.7. Compute internals for 20 marks as sum of cells Internal Test (15) and Attendance (5).
8. Enter university exam marks.
9. Convert external to 80 marks using ROUND function.
10. Compute Total marks as sum of Internal and External marks.
11. Determine Grade for each subject using nested IF. The formula isIF(K19>90, "S", IF(K19>80, "A", IF(K19>70, "B", IF(K19>60, "C", IF(K19>55, "D", IF(K19>=50,"E", "U"))))))
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.5
Output
Subject Grade
SubjectCode
Test1(100)
Test2(100)
Test3(100) Avg Intern
al (15)Att(5)
Internal(20)
UnivExam(100)
External(80)
TotalMark(100)
Grade
HS6151 80 70 92 80.7 12 5 17 91 73 90 A
MA6151 50 32 62 48.0 7 1 8 72 58 66 C
PH6151 20 0 50 23.3 4 0 4 50 40 44 U
CY6151 67 53 72 64.0 10 2 12 74 59 71 B
GE6151 50 50 62 54.0 8 3 11 60 48 59 D
GE6152 50 24 60 44.7 7 4 11 50 40 51 E
GE6161 94 94.0 14 5 19 92 74 93 S
GE6162 90 90.0 14 5 19 90 72 91 S
Result
The student’s grade in various subjects was obtained using built-in functions in excel.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.6
Exp. No. 2c EMPLOYEE PAYROLL
Aim
To compute payroll for employees based on their basic pay and sort the list.
Procedure
1. Enter the employee name, department and their basic pay.
2. Compute the allowances and deductions as fixed percentage of basic pay (cell C3).a) HRA = 0.18 * C3b) DA = 0.15 * C3c) TA = 0.09 * C3d) PF = 0.1 * C3
3. Calculate Gross = Basic + HRA + DA + TA
4. Determine IT based on their Gross pay (cell J3) with varying percentage using IFIF(J3*12>1000000, 0.3*J3, IF(J3*12>800000, J3*0.25, IF(J3*12>500000, J3*0.2,IF(J3*12>200000, J3*0.1, 0))))
5. Compute Net Pay = Gross – (PF + IT)6. Drag to copy the formula for all other rows.
7. The details can also be viewed column wise by selecting Filter in Data tab.a) All column headers now appear with a drop down symbol.b) Click Dept drop down list and select Testing to view Testing department details.
8. Select all data including header and click Sort in Data tab. In Sort dialog:a) Choose Sort by Dept and Order as A to Z for level1.b) Choose Sort by Gross and Order as Largest to Smallest for level2.c) Choose Sort by Name and Order as A to Z for level3.
9. Select sorted data incl. header and click Subtotal in Data tab. In Subtotal dialog:a) Select Dept for At each change inb) Check option Net Pay in Add subtotal toc) Check options Replace current subtotals and Summary below data.
Result
The employee’s pay was computed and sorted department wise.
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.7
Output
Employee Pay RollName Dept Basic HRA DA TA PF IT Gross Net PayYamini Testing 12000 2160 1800 1080 1200 1704 17040 14136
Sriraman Development 11500 2070 1725 1035 1150 0 16330 15180
Vigneshwaran Testing 29000 5220 4350 2610 2900 4118 41180 34162
Naveen Design 15000 2700 2250 1350 1500 2130 21300 17670
Sandhiya Admin 12000 2160 1800 1080 1200 1704 17040 14136
Manikandan R&D 35000 6300 5250 3150 3500 9940 49700 36260
Varun Admin 18000 3240 2700 1620 1800 2556 25560 21204
Raj Kumar Development 25000 4500 3750 2250 2500 3550 35500 29450
Raja Guru Design 28000 5040 4200 2520 2800 3976 39760 32984
Saravanan Testing 22000 3960 3300 1980 2200 3124 31240 25916
Sakthi Priyaa R&D 19000 3420 2850 1710 1900 2698 26980 22382
Employee Pay Roll (after sort & subtotal)Name Dept Basic HRA DA TA PF IT Gross Net PayVarun Admin 18000 3240 2700 1620 1800 2556 25560 21204
Sandhiya Admin 12000 2160 1800 1080 1200 1704 17040 14136
Admin Total 35340
Raja Guru Design 28000 5040 4200 2520 2800 3976 39760 32984
Naveen Design 15000 2700 2250 1350 1500 2130 21300 17670
Design Total 50654
Raj Kumar Development 25000 4500 3750 2250 2500 3550 35500 29450
Sriraman Development 11500 2070 1725 1035 1150 0 16330 15180
Development Total 44630
Manikandan R&D 35000 6300 5250 3150 3500 9940 49700 36260
Sakthi Priyaa R&D 19000 3420 2850 1710 1900 2698 26980 22382
R&D Total 58642
Vigneshwaran Testing 29000 5220 4350 2610 2900 4118 41180 34162
Saravanan Testing 22000 3960 3300 1980 2200 3124 31240 25916
Yamini Testing 12000 2160 1800 1080 1200 1704 17040 14136
Testing Total 74214Grand Total 263480
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.8
Exp. No. 2d ELECTRICITY BILL
Aim
To design electricity bill format and determining charges by importing data from text file.
Procedure
1. Create a text file eb.txt with each line consisting of unit and amount separated by tab up to500 units.
2. Insert a new worksheet by clicking Insert Insert Sheet in Home tab. Right click on sheetname and Rename the sheet to EBData
3. Click From Text in Data tab. and select eb.txt file. Click Next until Finish in Text ImportWizard to import the text file onto excel.
4. Design the electricity bill format on a worksheet.
5. Insert the EB logo by choosing Clip Art in Insert tab.
6. Insert the system date by clicking Date & Time TODAY in Formulas tab. Right click oncell and click Format Cells and choose the appropriate Time format.
7. Insert the system date by clicking Date & Time NOW in Formulas tab. Right click on celland click Format Cells and choose the appropriate Date format.
8. Right click on connection number, name, CMR, LMR cells and uncheck the Locked featurein Protection tab in Format Cells menu.
9. Calculate Units = CMR – LMR
10. Amount is obtained by clicking Lookup & Reference VLOOKUP in Formulas tab.a) Assign cell address containing units value for Lookup_valueb) Select the range of cells in EBData sheet for Table_arrayc) Enter value 2 for Col_index_num to return amount for the respective unit.d) Type FALSE in Range_lookup to find the exact match.
11. Click Print Area in Page Layout tab to set the section of sheet for printout.
12. Protect the worksheet by clicking Protect Sheet in Review tab and specify a password.
Result
The electricity bill is printed using import and protection features
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
X.9
Output
Tamil Nadu Electricity BoardChennai South Circle
Kelambakkam-603 103
Date : 3-Nov-2013 Time : 21:46
Conn. No : 128-45-122 Name : Vijai Anand
CMR LMR Units Amount(in Rs.)
61000 60760 240 362
Authorized Signatory
Units Rate/unit Units Rate/unit<= 100 1.10 201-500 3.50
101-200 1.80 > 500 5.75
GE6161–Computer Practice Lab
cseannauniv.blogspot.com Vijai Anand
P1
Ex. No. 3a MY INSTITUTION
AimTo create a presentation that highlights the institution facilities.
Procedure
1. Design the master slide by clicking Slide Master in View tab with background, Fonts,bullets, borders, footers, etc.
2. Choose the appropriate slide layout by clicking Layout in Home tab and type the textin the corresponding places.
3. To add a slide, click New Slide in Home tab. The master slide design is repainted onthe new slide.
4. To insert picture, chart, table, sound or graphic choose the appropriate options fromInsert tab.
5. To have animation effects use Custom Animation in Animations tab and chooseappropriate animation scheme for the slide elements
6. To have animation effects between slides choose an effect from Transition to ThisSlide in Animations tab.
7. To display the presentation, click an option From Beginning/From Current Slide/etcin Slide Show tab.
8. To print multiple slides per page select Handouts in Print Dialog and specify thenumber of slides per page.
Presentation Guidelines
1. The first slide should mention the topic clearly and speaker details2. The second slide should be an outline of the presentation
a) Only place main points (titles of other slides)b) Follow the order of outline
3. Write in point form, not complete sentences.a) 4-5 points per slide. Show one point at a time
4. Do not go overboard with animation. Be consistent5. Use different size fonts for main points and secondary points6. Use a font color that contrasts with the light background7. Use graphs and charts rather than words8. Proof the slides for spelling mistakes9. Conclusion slide should summarize and suggest future avenues10. Invite audience to ask questions.
ResultAn effective and elegant presentation about the institution using PowerPoint is
created.
1
SMK FOMRA INSTITUTE OFTECHNOLOGY
2
CourseInfrastructurePlacementCampus LifeContact Info
3
Course
B.E. Computer Science EngineeringB.Tech. Information TechnologyB.E. Electronic and CommunicationB.E. Electrical and Electronic EngineeringB.E. Bio Medical EngineeringB.E. Mechanical EngineeringMaster of Computer ApplicationMaster of Business Administration
4
InfrastructureAn inbuilt area of 2,86,000 sq.m.24-hour internet facility and wi-fi campusElectric supply supported by 2 generatorsSafe and cool drinking waterFully air-conditioned conference hallAir-conditioned library blockSeparate Boys Hostel and Girls HostelCanteenTemple
5
Placement
Train Students to become employableEstablish Industry Institute InteractionGuide Students for taking up higherstudiesCreate awareness about EntrepreneurshipOur Alumni are placed in leadingcorporate
6
12
9
15
2 2
8
1112
13
5
8
11
1
4
02468
10121416
Placements
CSE IT ECEDepartment
Software Placement as on Oct 2010
HCLTCSCTSInfosysAccenture
7
Campus Life
A world, rich in opportunity for personalgrowth and fulfillmentExciting and dynamicGuest lectures by eminent personalitiesIndustrial visitsTraining on self-awareness, attitude andmoral value programmes
8
Contact Info
SMK Fomra Institute of TechnologyOld Mahabalipuram Road,Thaiyur Village,Kelambakkam–603103.
Ph: 27475621/22
Web: www.smkfomra.net
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.1
Ex. No. 4a CIRCLE AREA
Aim
To compute area and circumference of a circle using value of (constant).
Algorithm
Step 1 : Start
Step 2 : Define constant pi= 3.14
Step 3 : Read the value of radius
Step 4 : Calculate areausing formulae pi*radius2
Step 5 : Calculate circumference using formulae 2*pi*radius
Step 6 : Print area and circumference
Step 7 : Stop
Flowchart
Read radius
pi = 3.14
area = pi * radius2
circumference = 2 * pi * radius
Print area, circumference
Start
Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.2
Program
/* Area and circumference of a circle */
#include <stdio.h>#include <conio.h>
#define pi 3.14
main(){
int radius;float area, circum;clrscr();printf("Enter radius of the circle : ");scanf("%d", &radius);area = pi * radius * radius;circum = 2 * pi * radius;printf("Area is %.2f and circumference is %.2f",
area,circum);getch();
}
Output
Enter radius of the circle : 8Area is 200.96 and circumference is 50.24
Result
Thus area and circumference of a circle is computed.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.3
Ex. No. 4b QUADRATIC EQUATION
Aim
To determine roots of a real type quadratic equationax2+ bx + c = 0.
Algorithm
Step 1 : Start
Step 2 : Read co-efficient values of a,band c
Step 3 Compute roots r1 = and r2 =
Step 4 : Print r1, r2
Step 5 : Stop
Flowchart
Read a, b, c
r1 =
r2 =
Print r1, r2
Start
Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.4
Program
/* Roots of Quadratic Equations ax^2 + bx + c = 0 */
#include <stdio.h>#include <conio.h>#include <math.h>
main(){
int a, b, c, d;float r1, r2;
clrscr();printf("Enter co-efficient for x^2 : ");scanf("%d", &a);printf("Enter co-efficient for x : ");scanf("%d", &b);printf("Enter const co-efficient : ");scanf("%d", &c);
d = b*b - 4*a*c;r1 = (-b + sqrt(d)) / (2.0 * a);r2 = (-b - sqrt(d)) / (2.0 * a);printf("Real roots are %.2f and %.2f", r1, r2);
getch();}
Output
Enter co-efficient for x^2 : 2Enter co-efficient for x : 8Enter const co-efficient : 6Real roots are -1.00 and -3.00
Result
Thus roots of a quadratic equation were obtained using math library functions.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.5
Ex. No. 5a LEAP YEAR
Aim
To checkwhether the given year is a leap year or not using if statement.
Algorithm
Step 1 : Start
Step 2 : Read the value of year
Step 3 : If year divisible by 400 then print "Leap year"
Step 3.1 : Else if year divisible by 4 and not divisible by 100 then print "Leap year"
Step 3.2 : Else print "Not a leap year"
Step 4 : Stop
Flowchart
YN
Y
N
Read year
Start
Stop
year%400=0?
year%4 = 0 andyear%100 0
?
Print"Leap"
Print "NotLeap"
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.6
Program
/* Leap Year */
#include <stdio.h>#include <conio.h>
main(){
int year;clrscr();
printf("Enter the year : ");scanf("%d", &year);
if (year%400 == 0)printf("%d is a Leap year",year);
else if (year%100 != 0 && year%4 == 0)printf("%d is a Leap year",year);
elseprintf("%d is not a Leap year",year);
getch();
}
Output
Enter the year : 20002000 is a Leap year
Enter the year : 18001800 is not a Leap year
Enter the year : 20042004 is a Leap year
Result
Thus the given year is determined as leap or not using if conditional construct.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.7
Ex. No. 5b SIMPLE CALCULATOR
Aim
To write a menu drivensimple calculator program using switch case.
Algorithm
Step 1 : Start
Step 2 : Display calculator menu options
Step 3 : Read the operatorsymboland operands n1, n2
Step 4 : If operator = + then calculate result = n1 + n2
Step 4.1 : Else if operator = – then calculate result = n1 – n2
Step 4.2 : Else if operator = * then calculate result = n1 * n2
Step 4.3 : Else if operator = / then calculate result = n1 / n2
Step 4.4 : Else if operator = % then calculate result = n1 % n2
Step 4.2 : Else print "Invalid operator" and go to step 6
Step 5 : Print result
Step 6 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.8
Flowchart
Other%/*–+
Display Calculator menu
Start
Stop
operator?
Print resOperator"
Read operator, n1, n2
res=n1+n2 res=n1–n2 res=n1*n2 res=n1/n2 res=n1%n2
Print "Invalidoperator"
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.9
Program
/* Simple Calculator */
#include <stdio.h>#include <stdlib.h>#include <conio.h>
main(){
int n1, n2, result;char op;clrscr();printf("\n Simple Calculator");printf("\n + Summation");printf("\n - Difference");printf("\n * Product");printf("\n / Quotient");printf("\n % Remainder");printf("\nEnter the operator : ");op = getchar();printf("Enter operand1 and operand2 : ");scanf("%d%d",&n1,&n2);
switch(op){
case '+':result = n1 +n2;break;
case '-':result = n1 - n2;break;
case '*':result = n1 * n2;break;
case '/':result = n1 / n2;break;
case '%':result = n1 % n2;break;
default:printf("Invalid operator");exit(-1);
}printf("%d %c %d = %d", n1, op, n2, result);getch();
}
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.10
Output
Simple Calculator + Summation - Difference * Product / Quotient % RemainderEnter the operator : -Enter operand1 and operand2 : 2 42 - 4 = -2
Simple Calculator + Summation - Difference * Product / Quotient % RemainderEnter the operator : %Enter operand1 and operand2 : 5 25 % 2 = 1
Result
Thus simple calculator functionality was executed using menu-oriented approach.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.11
Ex. No. 5c BINARY TO DECIMAL
Aim
To convert binary number into its decimal equivalent using while loop.
Algorithm
Step 1 : Start
Step 2 : Read the binary value
Step 3 : Initialize dec and i to 0
Repeat steps 4–7 until binary> 0
Step 4 : Extract the last digit using modulo 10
Step 5 : Calculate decimal = decimal + digit * 2i
Step 6 : Recomputebinary = binary / 10
Step 7 : Increment i by 1
Step 8 : Print decimal
Step 9 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.12
Flowchart
N
Y
Read binary
decimal = i = 0
binary>0?
digit = binary % 10decimal = decimal + digit * 2i
binary = binary / 10i = i + 1
Print decimal
Start
Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.13
Program
/* Binary to Decimal */
#include <stdio.h>#include <math.h>#include <conio.h>
main(){
int dec=0,i=0, d;long bin;clrscr();printf("Enter a binary number : ");scanf("%ld", &bin);
while(bin){
d = bin % 10;dec = dec + pow(2,i) * d;bin = bin/10;i = i + 1;
}
printf("Decimal Equivalent is %d", dec);getch();
}
Output
Enter a binary number : 1101011Decimal Equivalent is 107
Result
Thus decimal to binary conversion is done using while loop.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.14
Ex. No. 5d PRIME NUMBER
Aim
To determine whether the given number is prime using for loop.
Algorithm
Step 1 : Start
Step 2 : Read the value of n
Step 3 : Initialize i to 2 and flg to 0
Repeat steps 4 and 5 until i n/2
Step 4 : If n is divisible by i then assign 1 to flg and go toStep6
Step 5 : Increment i by 1
Step 6 : If flg = 0 then print "Prime"
Step 6.1 : Else print "Not prime"
Step 7 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.15
Flowchart
YN
N
N
Y
Read n
i = 2, flg = 0
i n/2?
Start
n%i = 0?
flg = 1Y
i = i + 1
Print "Prime"
Stop
flg = 0?
Print "Not Prime"
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.16
Program
/* Prime number */
#include <stdio.h>#include <conio.h>
main(){
inti,n,flg=0;clrscr();printf("\nEnter a number : ");scanf("%d", &n);
for(i=2; i<=n/2; i++){
if (n%i == 0){
flg = 1;break;
}}
if (flg == 0)printf("The given number is prime");
elseprintf("The given number is not prime");
getch();}
Output
Enter a number : 27The given number is not prime
Enter a number : 43The given number is prime
Result
Thus the given number is checked for prime with the help of break statement inlooping.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.17
Ex. No. 6a ARRAY MINIMUM / MAXIMUM
Aim
To find the largest and smallest element of the given array
Algorithm
Step 1 : Start
Step 2 : Read the number of array elements as n
Step 3 : Set up a loop and read array elements Ai, i = 0,1,2,…n–1
Step 4 : Assume the first element A0 to be min and max
Step 5 : Initialize i to 1
Repeat steps 6–8 until i<n
Step 6 : If max <Ai thenmax = Ai
Step 7 : If min >Ai then min = Ai
Step 8 : Increment i by 1
Step 9 : Print max, min
Step 10 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.18
Flowchart
N
Y
Y
N
Read n
max < Ai?
Start
Stop
i = 0 to n–1
Read Ai
i
min = max = A0
i = 1 to n–1
max = Ai
min > Ai?
min = Ai
i
Print min, max
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.19
Program
/* Maximum and Minimum of an array */
#include <stdio.h>#include <conio.h>
main(){
int a[10];int i, min, max, n;clrscr();printf("Enter number of elements : ");scanf("%d", &n);
printf("Enter Array Elements\n");for(i=0; i<n; i++)
scanf("%d", &a[i]);
min = max = a[0];for(i=1; i<n; i++){
if (max < a[i])max = a[i];
if (min > a[i])min = a[i];
}printf("Maximum value = %d ", max);printf("\n Minimum value = %d", min);getch();
}
Output
Enter number of elements : 6Enter Array Elements38-711-90Maximum value = 11Minimum value = -9
Result
Thus minimum and maximum of an array was obtained using array indexing.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.20
Ex. No. 6b MATRIX MULTIPLICATION
Aim
To compute product of two matricesusing two dimensional array.
Algorithm
Step 1 : Start
Step 2 : Read the order of matrix A as m and n
Step 3 : Read the order of matrix B as p and q
Step 4 : If n p then print "Multiplication not possible" and Stop
Step 5 : Set up a loop and read matrix A elements Aij, i = 0 to m-1and j = 0 to n-1
Step 6: Set up a loop and read matrix B elements Bij, i = 0 to p-1and j = 0 to q-1
Step 7 : Initialize i to zero
Step 8 : Initialize j to zero
Step 9 : Assign 0 toCij
Step 10 : Initialize k to zero
Step 11 : Compute Cij = Cij + Aik * Bkj
Step 12 : Increment kby 1
Repeat steps 11 and 12 untilk<n
Step 13 : Increment jby 1
Repeat steps 9–13 untilj<q
Step 14 : Increment iby 1
Repeat steps 8–14 untili<m
Step 15 : Set up a loop and print product matrix Cij,i = 0 to m-1 and j = 0 to q-1
Step 16 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.21
Flow Chart
Y
N
Read m, n
Start
i = 0 to m–1
Read Aij
j
j = 0 to n–1
n=p?
X
Read p, q
Print min, max
i
2
i = 0 to p–1
j = 0 to q–1
Read Bij
j
i
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.22
2
Stop
i = 0 to m–1
j
j = 0 to q–1
i
Cij = 0
k = 0 to n–1
Cij = Cij + Aik * Bkj
k
i = 0 to m–1
Print Cij
j
j = 0 to q–1
i
X
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.23
Program
/* Matrix Multiplication */
#include <stdio.h>#include <conio.h>
main(){
int a[10][10], b[10][10], c[10][10];int r1, c1, r2, c2;inti, j, k;
clrscr();printf("Enter order of matrix A : ");scanf("%d%d", &r1, &c1);printf("Enter order of matrix B : ");scanf("%d%d", &r2, &c2);
if (c1 != r2){
printf("Matrix multiplication not possible");getch();exit(0);
}
printf("Enter matrix A elements\n");for(i=0; i<r1; i++){
for(j=0; j<c1; j++){
scanf("%d", &a[i][j]);}
}printf("Enter matrix B elements\n");for(i=0; i<r2; i++){
for(j=0; j<c2; j++){
scanf("%d", &b[i][j]);}
}
for(i=0; i<r1; i++){
for(j=0; j<c2; j++){
c[i][j] = 0;
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.24
for(k=0; k<c1; k++){
c[i][j] += a[i][k] * b[k][j];}
}}
printf("Product matrix C\n");for(i=0; i<r1; i++){
for(j=0; j<c2; j++){
printf("%-4d",c[i][j]);}printf("\n");
}getch();
}
Output
Enter order of matrix A : 2 3Enter order of matrix B : 3 2Enter matrix A elements1 1 11 1 1Enter matrix B elements2 22 22 2Product matrix C6 66 6
Enter order of matrix A : 3 3Enter order of matrix B : 2 3Matrix multiplication not possible
Result
Thus product of given two matrices was obtained using arrays.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.25
Ex. No. 7a PALINDROME
Aim
To determine whether the input string is palindrome using string handling functions.
Algorithm
Step 1 : Start
Step 2 : Read the string, say str
Step 3 : Copy str onto rev using strcpy function
Step 4 : Reverse rev using strrev function
Step 5 : Compare str and rev using strcmp function
Step 6: If outcome of comparison is zero then
Step 6.1 Print "Given string is palindrome"
Step 6.2: Else Print "Given string is not palindrome"
Step 7 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.26
Flow Chart
YN
Read str
x = 0?
Start
Stop
Print"Not Palindrome"
strcpy(rev, str)strrev(rev)x = strcmp(rev, str)
Print"Palindrome"
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.27
Program
/* Palindrome using string functions */
#include <string.h>#include <stdio.h>#include <conio.h>
main(){
charstr[40],rev[40];int x;clrscr();printf("Enter the string: ");scanf("%s", str);
strcpy(rev, str);strrev(rev);printf("Reversed string is: %s\n", rev);
x = strcmp(str, rev);if (x==0)
printf("The given string is a palindrome");else
printf("The given string is not a palindrome");
getch();}
Output
Enter the string:malayalamReversed string is:malayalamThe given string is a palindrome
Enter the string: ComputerReversed string is:retupmoCThe given string is not a palindrome
Result
Thus the given input string is checked for palindrome using string handling functions.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.28
Ex. No. 7b ALPHABETICAL ORDER
Aim
To arrange names in theiralphabetic order using bubble sort method.
Algorithm
Step 1 : Start
Step 2 : Read number of name as n
Step 3 : Set up a loop and read the name list in name array
Step 4 : Assign 0 to i
Step 5 : Assign i+1 to j
Step 6: If namei>namej then swap the strings namei and namej
Step 7 : Increment j by 1
Repeat steps 6 and 7 until j<n
Step 8 : Increment i by 1
Repeat steps 5–8 until i<n-1
Step 9 : Set up a loop and print the sorted namearray
Step 10 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.29
Flow Chart
Y
N
Read n
strcmp(stri strj) > 0?
Start
Stop
i = 0 to n–1
Read stri
i
j = i+1 to n–1
Swap strings
i
i = 0 to n–2
j
i = 0 to n–1
Print stri
i
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.30
Program
/* Sorting strings */
#include <stdio.h>#include <conio.h>#include <string.h>
main(){
char name[20][15], t[15];int i, j ,n;clrscr();printf("Enter number of students : ");scanf("%d", &n);printf("Enter student names\n");for(i=0; i<n; i++)
scanf("%s", name[i]);
/* Bubble Sort method */for(i=0; i<n-1; i++){
for(j=i+1; j<n; j++){
if (strcmp(name[i],name[j]) > 0){
strcpy(t, name[i]);strcpy(name[i], name[j]);strcpy(name[j], t);
}}
}
printf("\nAlphabetical Order\n");for(i=0; i<n; i++)
printf("%s\n", name[i]);getch();
}
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.31
Output
Enter number of students :10Enter student namesRaghuPrabaGopalAnandVenkatKumarSaravanaNareshChristoVasanth
Alphabetical OrderAnandChristoGopalKumarNareshPrabaRaghuSaravanaVasanthVenkat
Result
Thus the given set of names were sorted in alphabetical order using string handlingfunction.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.32
Ex. No. 8a SINE SERIES
Aim
To generate value of sine series!7!5!3
753 xxxx using function.
Algorithm
Step 1 : Start
Step 2 : Read sine degree as deg
Step 3 : Convert degree to radians using the formula x = deg * / 180
Step 4 : Call sinecalc function with parameter x
Step 5 : Print computed value of sine series
Step 6: Stop
sinecalc Function
Step 1 : Assign x to term and sum
Repeat steps 3 and 4 until term<0.00001
Step 2 : Compute new term as term = term * x2 / (2i (2i+1))
Step 3 : Alternatively subtract and add term to sum
Step 4 : Return sum
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.33
Flow Chart
Y
N
Read deg, n
Start
sgn = -sgnterm = term * x2 / (2i (2i+1))sum = sum + sgn * term
sgn = 1sum = term = x
Print sinevalue
Stop
sinecalc (x)
x = deg * 3.14 / 180
Return (sum)
term> 0.00001
Call sinevalue = sinecalc(x)
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.34
Program
/* Sine series */
#include <stdio.h>#include <math.h>
#define pi 3.14
floatsinecalc(float, int);
main(){
int deg, n;float x, sineval;
clrscr();printf("Enter Sine degree : ");scanf("%d", °);printf("Enter no. of terms : ");scanf("%d", &n);
x = deg*pi/180;sineval = sinecalc(x);
printf("\nGenerated series value : %.4f", sineval);printf("\nBuilt-in function value : %.4f", sin(x));printf("\nComputational error\t : %.4f", sin(x)-sineval);getch();
}
floatsinecalc(float x){
int i=1,sgn=1;float sum,term;
sum = term = x;while (1){
if (term < 0.00001) break;printf("\nThe term is %.4lf and sum is %.4lf",
term, sum);sgn = -sgn;term *= x*x / (2*i * (2*i+1));sum += sgn *term;i++;
}return (sum);
}
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.35
Output
Enter Sine degree: 73
The term is 1.2734 and sum is 1.2734The term is 0.3442 and sum is 0.9293The term is 0.0279 and sum is 0.9572The term is 0.0011 and sum is 0.9561The term is 0.0000 and sum is 0.9561
The value of Generated Sine series is 0.9561Value using built-in function is 0.9561Computational error is 0.0000
Result
Thus value of sine series is computed using user-defined function with negligibleerror factor.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.36
Ex. No. 8b PASS BY VALUE/REFERENCE
Aim
To demonstrate parameters passing to a function, both by value and reference.
Algorithm
Step 1 : Start
Step 2 : Assign 10 to a and 20 to b
Step 3 : Print a and b
Step 4 : Call swapval function with values of a and b
Step 5 : Print a and b
Step 6 : Call swapref function with address of a and b
Step 7 : Print a and b
Step 8 : Stop
swapval Function
Step 1 : t = a
Step 2 : a = b
Step 3 : b = t
Step 4 : Return
swapref Function
Step 1 : t = *a
Step 2 : *a = *b
Step 3 : *b = t
Step 4 : Return
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.37
Flow Chart
Start
Return
Print a, b
Stop
swapval (a, b)
a = 10b = 20
Print a, b
Print a, b
t = aa = bb = t
Return
swapref (*a, *b)
t = *a*a = *b*b = t
Call swapval(a, b)
Call swapref(&a, &b)
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.38
Program
/* Pass by value and reference */
#include <stdio.h>#include <conio.h>
void swapval(int, int);void swapref(int *,int *);
main(){
int a = 10, b = 20;
clrscr();printf("\nValues before function calls\n");printf("Value of A : %d\n", a);printf("Value of B : %d\n", b);
swapval(a,b);printf("\nValues after Pass by Value\n");printf("Value of A : %d\n", a);printf("Value of B : %d\n", b);
swapref(&a,&b);printf("\nValues after Pass by Reference\n");printf("Value of A : %d\n", a);printf("Value of B : %d", b);getch();
}
/* Pass by value */void swapval(inta,int b){
int t;t = a;a = b;b = t;
}
/* Pass by Reference*/void swapref(int *x,int *y){
int t;t = *x;*x = *y;*y = t;
}
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.39
Output
Values before function callsValue of A : 10Value of B : 20
Values after Pass by ValueValue of A : 10Value of B : 20
Values after Pass by ReferenceValue of A : 20Value of B : 10
Result
Thus two types parameter passing namely pass-by-value and pass-by-reference wasdone using swapping example.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.40
Ex. No. 9a FACTORIAL RECURSION
Aim
To compute factorial value of a given number n! = n * (n-1)!usingrecursion.
Algorithm
Step 1 : Start
Step 2 : Read the value of n
Step 3 : Call factorial function with parametern
Step 4 : Print factorial value
Step 5: Stop
factorial Function
Step 1 : If n=1 then return 1
Step 1.1 : Else return n*factorial(n-1)
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.41
Flow Chart
Read n
Start
Return (1)
Print factvalue
Stop
factorial(n)
n = 1?
Y N
Call factvalue = factorial(n)
Return (n * factorial(n-1))
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.42
Program
/* Factorial--Recursion */
#include <stdio.h>#include <conio.h>
long factorial(int);
main(){
int n;longint f;clrscr();printf("Enter a number : ");scanf("%d", &n);f = factorial(n);printf("Factorial value : %ld", f);getch();
}
long factorial(int n){
if (n<=1)return(1);
elsereturn (n * factorial(n-1));
}
Output
Enter a number : 6Factorial value : 720
Enter a number : 12Factorial value : 479001600
Result
Thus factorial value of a given number was obtained through recursive function call.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.43
Ex. No. 9b FIBONACCI RECURSION
Aim
To generate Fibonacci series using recursion.
Algorithm
Step 1 : Start
Step 2 : Read number of terms, say n
Step 3 : Loop i from 0 to n and
Step 3.1 : Call fibo (i)
Step 4: Stop
fibo Function
Step 1 : If n = 1 then return 1
Step 1.1 : Else if n=0, then return 0
Step 1.2 : Else return fibo (n-1) + fibo (n-2)
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.44
Flow Chart
Read n
Start
Return (0)
Stop
fibo(n)
n = 1?
Y
N
Return (fibo (n-1) + fibo (n-2))
n = 0?
Return (1)
NY
i = 0 to n
i
Print fibo(i)
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.45
Program
/* Fibonacci series using Recursion */
#include <stdio.h>#include <conio.h>
int fibo(int);
main(){
int i, n;
clrscr();printf("Enter no. of terms : ");scanf("%d",&n);
for (i = 0; i< n; i++)printf("%d ", fibo(i));
getch();}
int fibo(int num){
if (num == 1)return 1;
else if (num == 0)return 0;
elsereturn fibo(num - 1) + fibo(num - 2);
}
Output
Enter no. of terms :100 1 1 2 3 5 8 13 21 34
Result
Thus Fibonacci series was generated using recursive function call.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.46
Ex. No. 10a PAYROLL APPLICATION
Aim
To generate employee payroll for anorganization using structure.
Algorithm
Step 1 : Start
Step 2 : Defineemployee structure with fields empid, ename, basic, hra, da, it, gross andnetpay
Step 3 : Read number of employees n
Step 4 : Set up a loop and read empid, ename, and basic for n employees in emp array
Set up a loop and do steps 5–9 for n employees
Step 5 : hra = 2% of basic
Step 6 : da = 1% of basic
Step 7 : gross = basic + hra + da
Step 8 : it = 5% of basic
Step 9 : netpay = gross - it
Step 10: Print company and column header
Step 11 Set up a loop and print empid, ename, basic, hra, da, it, gross and netpay foreach employee in emp array
Step 12 : Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.47
Flow Chart
Start
Stop
Define emp structure
Read n
i = 0 to n-1
Read empi.empid,empi.name, empi.basic
i
i = 0 to n-1
i
empi.hra = 0.02 * empi.basicempi.da = 0.01 * empi.basicempi.it = 0.05 * empi.basicempi.gross = empi.basic +empi.hra +empi.daempi.netpay = empi.gross - empi.it
i = 0 to n-1
Print empi.empid, empi.name,empi.basic, empi.hra, empi.da,
empi.gross, empi.it, empi.netpay
i
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.48
Program
/* Payroll Generation */
#include <stdio.h>#include <conio.h>
struct employee{
int empid;char name[15];int basic;float hra;float da;float it;float gross;float netpay;
};
main(){
struct employee emp[50];int i, j, n;
clrscr();printf("\nEnter No. of Employees : ");scanf("%d", &n);
for(i=0; i<n ;i++){
printf("\nEnter Employee Details\n");printf("Enter Employee Id : ");scanf("%d", &emp[i].empid);printf("Enter Employee Name : ");scanf("%s", emp[i].ename);printf("Enter Basic Salary : ");scanf("%d", &emp[i].basic);
}
for(i=0; i<n; i++){
emp[i].hra = 0.02 * emp[i].basic;emp[i].da = 0.01 * emp[i].basic;emp[i].it = 0.05 * emp[i].basic;emp[i].gross = emp[i].basic+emp[i].hra+emp[i].da;emp[i].netpay = emp[i].gross - emp[i].it;
}
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.49
printf("\n\n\n\t\t\t\tXYZ& Co. Payroll\n\n");for(i=0;i<80;i++)
printf("*");printf("EmpId\tName\t\tBasic\t HRA\t DA\t IT\t
Gross\t\tNet Pay\n");for(i=0;i<80;i++)
printf("*");for(i=0; i<n; i++){
printf("\n%d\t%-15s\t%d\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f",emp[i].empid, emp[i].ename,emp[i].basic,emp[i].hra,emp[i].da, emp[i].it,emp[i].gross, emp[i].netpay);
}printf("\n");for(i=0;i<80;i++)
printf("*");getch();
}
Output
Enter No. of Employees : 2
Enter Employee DetailsEnter Employee Id : 436Enter Employee Name :GopalEnter Basic Salary : 10000
Enter Employee DetailsEnter Employee Id : 463Enter Employee Name :RajeshEnter Basic Salary : 22000
XYZ & Co. Payroll
********************************************************************************EmpId Name Basic HRA DA IT Gross Net Pay********************************************************************************
436 Gopal 10000 200.00 100.00 500.00 10300.00 9800.00463 Rajesh 22000 440.00 220.00 1100.00 22660.00 21560.00
********************************************************************************
Result
Thus payroll for employees was generated using structure.
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.50
Ex. No. 10b UNION USAGE
Aim
To store multiple data types in a single storage space using structure and union.
Algorithm
Step 1 : Start
Step 2 : Define symbolic constants for basic data types such as character, integer andfloat.
Step 3 : Declare a structure with member type and contains a union that has members ofdifferent basic types.
Step 4 : Store type of data in structure member type and value in corresponding memberof union.
Step 5 : Call print function and pass structure.
Step 6 : Stop
print function
Step 1: Based on type content, print the value using appropriate format specifier.
Step 2: Stop
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.52
Program
/* Union and Structure */
#include <stdio.h>
#define CHARACTER 'C'#define INTEGER 'I'#define FLOAT 'F'
struct generic_tag{
char type;union shared_tag{
char c;int i;float f;
} shared;};
void print(struct generic_tag);
main(){
struct generic_tag var;clrscr();
var.type = CHARACTER;var.shared.c = '$';print(var);
var.type = FLOAT;var.shared.f = 12345.67890;print(var);
var.type = 'x';var.shared.i = 111;print(var);getch();
}
void print(struct generic_tag generic){
printf("\nThe generic value is ");switch(generic.type){
case CHARACTER:printf("%c", generic.shared.c);break;
GE6161 – Computer Practice Lab
cseannauniv.blogspot.com VijaiAnand
C.53
case INTEGER:printf("%d", generic.shared.i);break;
case FLOAT:printf("%.2f", generic.shared.f);break;
default:printf("an unknown type");
}}
Output
The generic value is $The generic value is 12345.68The generic value is an unknown type
Result
Thus different data types were stored in the same area using union and structure.