Upload
archhhh
View
54
Download
0
Embed Size (px)
Citation preview
185151—COMPUTER PRACTICE LABORATORY I
LIST OF EXERCISES
a) Word Processing 15
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 15
5. Chart – Line, XY, Bar and Pie
6. Formula – formula editor
7. Spread sheet – inclusion of object, Picture and graphics, protecting thedocument and sheet
8. Sorting and Import / Export features
c) Simple C Programming 15
9. Data types, Expression evaluation, Condition statements
10. Arrays
11. Structures and Unions
12. Functions
TABLE OF CONTENTS
Ex. No Lab # Name of the experiment Page No.
1 MICROSOFT WORD 4
1.1 1 DOCUMENT FORMATTING 6
1.2 2 TABLE FORMATTING 9
1.3 3 MAIL MERGE 11
1.4 4 FLOW CHART 13
2 MICROSOFT EXCEL 15
2.1 5 CHART CREATION 17
2.2 6 FORMULA EDITOR 21
2.3 7 DATA SORTING 23
2.4 8 IMPORTING DATA 25
3 C PROGRAMMING 28
3.1 9 AREA OF A CIRCLE 30
3.2 9 BIGGEST OF TWO NUMBERS 32
3.3 10 LEAP YEAR 34
3.4 10 SIMPLE CALCULATOR 36
3.5 11 BINARY TO DECIMAL 40
3.6 11 PRIME NUMBER 43
3.7 12 ARRAY MINIMUM / MAXIMUM 46
3.8 12 MATRIX MULTIPLICATION 49
3.9 13 ALPHABETICAL ORDER 54
3.10 13 STRING REVERSE 58
3.11 14 SINE SERIES 61
3.12 14 RECURSIVE FUNCTION 65
3.13 15 PASS BY VALUE & REFERENCE 68
3.14 15 PAY ROLL APPLICATION 72
4 MICROSOFT POWERPOINT 76
4.1 16 MY INSTITUTION 78
185151— Computer Practice Laboratory–I
W.1
Ex. NO. 1—MICROSOFT WORD
Microsoft Word is a word processor that can be used to create, edit,
save and print personal as well as professional documents such as newsletter,
reports, letters, essays, etc in a very simple and efficient manner. We can type
text, make corrections, format paragraphs and text in different styles and
columns, check spelling, find synonyms for a word, insert pictures, merge letter
draft with database and process it in many more ways before we actually put
that page to print.
Getting Started
To start MS-Word, click Start Run and type winwordPress Ctrl + N to open a new document.To cut/copy the selected text, press Ctrl+X / Ctrl+C and to paste it at thedesired place, press Ctrl+VPress Ctrl + S to save the contents with extension .docTo print the document, choose Print from File menu.
.
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
W.2
Ex. No. 1.1–DOCUMENT FORMATTING
Aim:
To learn formatting options and to design a conference brochure.
Procedure:
Proof read the plain text using Spelling and Grammar from Tools menuFor heading text, choose appropriate heading style from style combo boxfrom the formatting toolbar.To apply font formatting, highlight the text and choose Font from Formatmenu. Select the font type, style (bold/italic/underline), size and color.The Font dialog also has options such as subscript, superscript, etc.To align the paragraphs choose Paragraph from Format menu.Alignment (left/right/center, justify), line spacing and indentation.To highlight important features, choose Bullets and Numbering fromFormat menu (Numbered for procedures, bullets for points)To insert picture choose Picture from Insert menu. Right click the pictureand choose format option for positioning picture along with text.Use format painter toolbar button to redo an existing formatting.To set watermark, choose Format Background Printed Watermark.Set Page/paragraph borders through Borders and Shading from FormatmenuNon-keyboard characters are inserted using Symbol from Insert menuTo have the page numbered choose Page Numbers from Insert menuTo type equations, choose Object from Insert menu and select Microsoftequation.For columnar text, select the text and choose Columns from Formatmenu and specify number of columns.To have tabbed formatting, choose Tabs from Format menu and set thetab position, alignment and leader.
Result:The various formatting options are used to design a conference brochure.
S.K. Vijai Anand cseannauniv.blogspot.com
OVERVIEW OF C
C as a programming language is rather like Pascal or Fortran. Values are stored in
variables. Programs are structured by defining and calling functions. Program flow is
controlled using loops, if statements and function calls.
Planning a computer program involves various interrelated tasks to be performed in asystematic manner. They are:
1. Identifying the purposeIdentifying parameters and constraints
2. Developing a programWriting the computer programDebugging the program
3. Executing the program
Write a program to compute the roots of a quadratic equation for the given polynomial
ax2+bx+c=0 usinga
acbb2
42
A high-level flowchart shows the majorsteps in a process It can also include theintermediate outputs of each step and thesub-steps involved. Such a flowchartoffers a basic picture of the process andidentifies the changes taking place withinthe process.
Most processes can be adequatelyportrayed in four or five boxes thatrepresent the major steps or activities ofthe process. In fact, it is a good idea to useonly a few boxes, because doing so forcesone to consider the most important steps.
Requirements—defines needed information, function, behavior,performance and interfaces.Design—data structures, software architecture, interface representations,algorithmic details.Implementation – source code, database, user documentation, testing.
FormulasCa(HCO3)2 = CaCO3 + CO2 + H2O(a + b)2 = a2 + b2 + 2ab
1. Introduction to Computers 1.1 Introduction....................................................................................................... 5 1.2 Evolution of Computers 1.2.1 Manual Computing Devices................................................................. 12 1.2.2 Automated Computing Devices ........................................................... 17
S.K. Vijai Anand cseannauniv.blogspot.com
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 ComputingParallel ComputingNetwork SecurityWireless 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 MS Word in IEEE format. The papersubmitted must be an original contribution andmust not have been published or presentedelsewhere earlier. Submitted papers will beassessed by two reviewers. For accepted papers,at least one of the authors must present the paperfor it to appear in the conference proceedings.
IMPORTANT DATESLast date for submission : 20th Feb. 2009Acceptance notification : 25th Feb. 2009Camera ready paper : 4th Mar. 2009Registration deadline : 18th Mar. 2009
REGISTRATION FEEStudents & 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,S.M.K Fomra Institute of Technology” payableat Chennai.
CONFERENCE COMMITTEE
Chief PatronsShri Sundarlal Fomra, Chairman, SMKFITShri Natwarlal Fomra, Trustee, SMKFITPatronsDr. N.V. Pundarikanthan, Director, SMKFITDr. L. Mahesh Kumar, Principal, SMKFITAdvisory CommitteeDr. Baldev Raj, Director, IGCARDr. S. Salivahanan, Principal, SSNCEDr. V. Vaidehi, Professor, MIT, Anna UniversityDr. M. Mukunda Rao, Advisor, SMKFITDr. N. Sankaranarayanan, Dean, SMKFITDr. S. Chandrasekar, Dean, SRCEConvenorDr. 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, BMEProf. S. Sivanandhan, Prof & Head, EEEMs. S. Chandravadhana, Head, ECEMr. J. Veeraraghavan, AP, IT
ADDRESS FOR CORRESPONDENCEThe Organizing Secretary, NCCCN ‘09S.M.K. Fomra Institute of TechnologyOMR, Thaiyur Village,Kelambakkam–603 103.Ph: 044-27475621/22E-mail: [email protected]: www.smkfomra.net
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
W.3
Ex. No. 1.2–TABLE FORMATTING
Aim:To create class timetable and employee pay details using tables.
Class Timetable:
1. Choose Insert from Table menu and select Table option and specifynumber of columns and rows as 10 and 6 respectively.
2. Choose Table AutoFormat from Table menu and select a style3. Select cells in 4th & 7th column, choose Merge Cells from Table menu4. Type Break and Lunch in the 4th and 7th column and choose Text
Direction from Format menu to change the text in vertical direction.5. For laboratory and consecutive periods, select and merge the cells.6. Enter the subject codes in the corresponding cells and complete the table.
Choose Table Properties from Table menu and select center in cell tab.7. Type subject code and subject title in another table. Choose Table
Convert Text to Table to convert the table data to text.
Employee Pay table:1. To create a table for employee details and choose the option AutoFit to
Contents in the Insert Table dialog2. To add new rows/column choose Insert from Table menu and specify
above/below for rows and left/right for columns3. To delete unwanted rows/column choose Delete from Table menu4. Enter the employee name and their basic in the table5. Compute 1st row of data by choosing Formula from Table menu as
HRA PRODUCT(B2,0.15)DA PRODUCT(B2,0.18)TA PRODUCT(B2,0.09)GROSS PAY SUM(LEFT)TOTAL SALARY SUM(ABOVE)
6. Choose Sort from Table menu and the sort the employee detailsaccording to name.
Result:The class timetable and employee details are represented in a structured
manner using tables.
S.K. Vijai Anand cseannauniv.blogspot.com
I CSE-B Time Table
18:40-9:25
29:25-10:10
310:20-11:05
411:05-11:45
512:15-1:15
61:15-2:15
72:15-3:15
Mon 181101 182101 186101 183101 185102 181101
Tue 185102 181101 183101 186101 185101
Wed 185102 182101 185101 184151
Thu 183101 185102 181101 183101 185152
Fri 182101 185151
BR
EAK
185151
LU
NC
H
181101 182101 186101
186101 Technical English - I181101 Mathematics - I182101 Engineering Physics - I183101 Engineering Chemistry - I185101 Engineering Graphics185102 Fundamentals of Computing and Programming185151 Computer Practice Laboratory -I185152 Engineering Practices Laboratory184151 Physics & Chemistry Laboratory I
Employee Details
Name Basic HRA DA TA Gross Pay
12000 1815 1800 1080 17040
29000 5220 4350 2610 41180
15000 2700 2250 1350 21300
16000 2880 2400 1440 22720
28000 5040 4200 2520 39760
18000 3240 2700 1620 25560
Total Salary 167560
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
W.4
Ex. No. 1.3–MAIL MERGE
Aim:
To merge the draft with student’s academic database using mail merge ona letter head.
Procedure:
1. To design letter head, choose Header and Footer from View menu andcreate a table without borders (a row and three columns) in the header.
2. Insert institute logo, ISO logo in 1st & 3rd column, and type institutename in the 2nd column. Insert a separator line at the header bottom.
3. Switch to Footer using the button in Header and Footer toolbar, typeaddress and contact information, preceded by a separator line.
4. Insert system date by choosing Date and Time from Insert menu5. Type the letter. Leave the recipient address and marks blank.6. To start mail merge, choose Letters and Mailings from Tools menu. A 6-
step mail merge wizard appears.7. In Step 1, select Letters as the document type and click next.8. In Step 2, select Use the current document as starting one and click next9. In Step 3, select Type a new list and click Create.10. A New Address List dialog with default fields appears. Click Customize
and change the structure with fields Parent name, Student name,Address, City, Zip code, Assess1, Assess2, Assess3 and Attendance.
11. Add record for each student by clicking New Entry. Finally click Close,save the data file and click next. A mail merge toolbar appears
12. In Step 4, click More items and insert the Parent name, Address, City,Zip code in the Recipient space. Insert Student name, Assess1, Assess2,Assess3 and Attendance fields at the appropriate place. Click next
13. In Step 5, preview the letter for each recipient by clicking the navigationbutton in the mail merge tool bar
14. Click next to complete the merge and either Print or Edit the letters.
Result:The letter draft is merged with the student database using mail merge on a
letter head.
S.K. Vijai Anand cseannauniv.blogspot.com
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:11-Jan-01FromThe Class Coordinator,I Year CSE-B,SMKFIT.
To«Parent_Name»,«Address»,«City»–«ZIP_Code».
Dear Parent,
Sub: Academic Performance—Reg.
This is to inform you that your son/daughter «Student_Name» has scored the
following marks in the assessment examinations and his attendance are given below:
Assesment-1 Assessment-2 Assessment-3 Attendance
«Assess1» «Assess2» «Assess3» «Attendance»
Yours truly,
(Class Coordinator)
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
W.5
Ex. No. 1.4–FLOW CHART
Aim:
To create flowchart for a program and course chart using Insert menu.
Flow Chart:
Enable the Drawing toolbar or choose Picture from Insert menu andselect Autoshapes, auto shape toolbar appears.The following symbols from Flowchart section of AutoShapes arecommonly used
Start / Stop
Input / Output
Process
Decision
Connector
To insert text, right click on the symbol and click Add TextConnect the symbols using connector or linesDraw the flowchart accordingly to the algorithm for the given problem
Hierarchy Chart:To create course chart, choose Diagram from Insert menu and select astyle (Outline). A organizational chart toolbar appearsTo add a node down the level, click insert shape and select SubordinateTo add a node at the same level, click insert shape and select CoworkerDesign the chart as shown and type text in the nodes by clicking on it.
Result:The flowchart for a given program and course chart is created using
Picture options from Insert menu.
S.K. Vijai Anand cseannauniv.blogspot.com
N
Y
Read n
rev = 0
n > 0?
d = n % 10rev = rev * 10 + dn = n / 10
Print rev
Start
Stop
Courses
Engineering Non-Engineering
UG
B.E—CSE
B.Tech—IT
B.E.—ECE
PG
B.E.—BME
MCA
MBA
PG
M.E—CSE
M.E—VLSI
B.E—EEE
B.E—Mech
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
X.1
Ex. No. 2–MICROSOFT EXCEL
Microsoft Excel is the most widely used and versatile spreadsheet
package. A spreadsheet is a table of 65536 rows and 256 columns into which
data is entered. Spreadsheet makes it possible to format data, manipulate using
functions, insert pictures, create charts and reports, import/export data, protect
sheet, etc and aids in data analysis.
Getting StartedTo start MS Excel, Start Run and type excel
To work with a new blank sheet click Ctrl + N.
Click Save from File menu to save the worksheet with extension .xls
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
X.2
Ex. No. 2.1–CHART CREATION
Aim:
To create appropriate charts for given set of data.
Procedure:
1. Enter data in the Worksheet including header and select all the cells.
2. Choose Chart from Insert menu. A 4-step Chart wizard appears.
3. In step 1 choose appropriate chart type from Chart Type dialoga. Choose Column chart for assessment performance datasetb. Choose Line chart for cricket match datasetc. Choose Pie chart for sales dataset
4. In step 2, specify Data range and Series name.a. For Column chart the data range series should be in Rowsb. For Line chart the data range series should be in Columnsc. For Pie chart the data range series should be in Columns
5. In step 3, enter the appropriate title in Titles tab, select Values from Datalegend tab (Percentage for Pie), uncheck gridlines.
Type Chart Title Category (X) axis Value (Y) axisColumn FOC Performance Assessment AggregateLine Ind vs Aus 1st ODI Overs RunsPie 1st Quarter sales 2010
6. In step 4, choose As object in for chart location and click finish button.
7. The chart is placed in the worksheet.
Result:
The respective charts were created for visual inference of data
S.K. Vijai Anand cseannauniv.blogspot.com
Department Assess-1 Assess-2 Assess-3EEE 56 67 78ECE 73 45 81IT 65 59 71CSE 89 74 50MECH 75 67 54
FOC Aggregate (in %)
FOC Performance
56
67
7873
45
81
6559
71
89
74
50
7567
54
0102030405060708090
100
Assess-1 Assess-2 Assess-3
Assessment
Agg
rega
te
EEEECEITCSEMECH
S.K. Vijai Anand cseannauniv.blogspot.com
Overs India Australia5 45 29
10 79 6515 97 8520 110 10525 125 13230 155 15035 175 18040 210 21545 240 23850 295 281
Ind vs Aus
Ind vs Aus 1st ODI
125
175
210
295
29
6585
240
155
11097
45
79
281
238215
180
150132
105
0
50
100
150
200
250
300
5 10 15 20 25 30 35 40 45 50
Overs
Run
s IndiaAustralia
S.K. Vijai Anand cseannauniv.blogspot.com
Product Sales (in Crores)Printers 234Scanner 90Fax 109MFNs 150Desktops 300Laptops 270Servers 100Acessories 450
First Quarter Sales
1st Quarter Sales 2010
14%
5%
6%
9%
18%16%
6%
26%PrintersScannerFaxMFNsDesktopsLaptopsServersAcessories
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
X.3
Ex. No. 2.2–FORMULA EDITOR
Aim:To determine rank and class for student marks.
Student Rank:
1. Select the cells in which marks are to be enteredChoose Conditional Formatting from Format menu and set Fontto red color for entries < 70Choose Validation from Data menu and set alert message forvalues outside the range 0 to 200
2. Enter the student name and their 6 subject marks in the worksheet.
3. Choose Function from Insert menu.
4. Compute total in cell H3 using the function SUM(B3:G3)
5. Compute result using the formula and sort the dataset according to resultIF(OR(B3<70, C3<70, D3<70, E3<70, F3<70), "Fail", "Pass")
6. The rank is determined using function RANK(H3, $H$3:$H$10). Useabsolute addressing to specify the range.
7. Compute Cutoff using the formula D3/2+E3/4+F3/48. Drag to copy the formula for all other rows
Student Grade:
1. Compute Best of 2 as (SUM(B19:D19)-MIN(B19:D19))/22. Convert test marks to 15 as ROUND(E19*0.15, 0)3. Compute Attendance marks as IF(G19>95, 5, IF(G19>90, 4, IF(G19>85,
3, IF(G19>80, 2, IF(G19>75, 1, 0)))))4. Compute Total marks as ROUND(J19*0.8 + I19,0)5. Grade is determined as IF(K19>90, "S", IF(K19>80, "A", IF(K19>70,
"B", IF(K19>60, "C", IF(K19>55, "D", IF(K19>=50, "E", "U"))))))
Result:The student’s performance was analyzed using various formulas.
S.K. Vijai Anand cseannauniv.blogspot.com
Name Lang Eng Maths Phy Chem CSc Total Result Rank Cutoff125 140 180 145 175 164 929 Pass 2 170.00
112 145 160 121 109 151 798 Pass 5 137.50
145 131 119 141 138 147 821 Pass 4 129.25
160 141 128 100 109 137 775 Pass 6 116.25
133 141 174 169 170 181 968 Pass 1 171.75
90 98 105 85 112 110 600 Pass 7 101.75
111 122 133 144 155 166 831 Pass 3 141.25
109 125 56 103 69 110 572 Fail
119 125 112 105 111 60 632 Fail
Reg.No Test1(100)
Test2(100)
Test3(100)
Bestof 2
Test(15)
Attend%
AttMarks
Intern(20)
Extern(100)
Total Mark(100) Grade
80 70 92 86.0 13.0 96 5 18 91 91 S
50 32 62 56.0 8.0 78 1 9 72 67 C
20 0 50 35.0 5.0 70 0 5 50 45 U
67 53 72 69.5 10.0 85 2 12 74 71 B
60 70 82 76.0 11.0 98 5 16 81 81 A
50 50 62 56.0 8.0 87 3 11 60 59 D
50 24 60 55.0 8.0 95 4 12 50 52 E
Student Grade
Student Rank
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
X.4
Ex. No. 2.3–DATA SORTING
Aim:
To compute net pay for employees based on their basic pay and sortaccording to their department.
Procedure:
1. Enter the employee name, department and their basic in the worksheet
2. Compute the allowances and deductions for basic entered in cell D3 as
HRA = 0.18 * D3DA = 0.15 * D3TA = 0.09 * D3PF = 0.1 * D3
3. Calculate Gross = Basic + HRA + DA + TA
4. Calculate IT based on their gross pay with varying percentage asIF(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. Calculate Net Pay = Gross – (PF + IT)
6. Drag to copy the formula for all other rows
7. Select all the dataChoose Sort from Data menu. Sort by Dept in Ascending and thenNet Pay in Descending order.Choose Subtotals from Data menu to calculate totals departmentwise and total
8. The details can also be viewed department wise by selecting Data FilterAutoFilter.
Result:
The employee’s pay was computed and sorted department wise.
S.K. Vijai Anand cseannauniv.blogspot.com
EmpIdName Dept Basic HRA DA TA PF IT Gross Net Pay1001 Accounts 12000 2160 1800 1080 1200 1704 17040 141361008 Accounts 29000 5220 4350 2610 2900 4118 41180 34162
Accounts Total 482981022 EDP 15000 2700 2250 1350 1500 2130 21300 176701023 EDP 16000 2880 2400 1440 1600 2272 22720 188481004 EDP 28000 5040 4200 2520 2800 3976 39760 32984
EDP Total 695021007 HR 12000 2160 1800 1080 1200 1704 17040 141361002 HR 18000 3240 2700 1620 1800 2556 25560 21204
HR Total 353401020 Maintenance 11500 2070 1725 1035 1150 0 16330 151801003 Maintenance 22000 3960 3300 1980 2200 3124 31240 259161017 Maintenance 25000 4500 3750 2250 2500 3550 35500 29450
Maintenance Total 705461005 Marketing 15000 2700 2250 1350 1500 2130 21300 176701015 Marketing 15000 2700 2250 1350 1500 2130 21300 176701016 Marketing 22000 3960 3300 1980 2200 3124 31240 25916
Marketing Total 612561019 R&D 19000 3420 2850 1710 1900 2698 26980 223821006 R&D 20000 3600 3000 1800 2000 2840 28400 235601011 R&D 35000 6300 5250 3150 3500 9940 49700 36260
R&D Total 82202Grand Total 367144
Employee Pay Details
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
X.5
Ex. No. 2.4–IMPORTING DATA
Aim:
To print electricity bill by importing charges from database file.
Procedure:
1. Create a database file (eb.mdb) with a table consisting two fields (units,amount) and store charges for respective units.
2. Click Data Import Data Import External Data to import data andselect eb.mdb file. The database is imported to a new worksheet andrename it Database.
3. Design the electricity bill format.
4. Insert the EB logo by choosing Picture from Insert menu.
5. Change the background by choosing Background under Sheet fromFormat menu
6. Insert the system date using TODAY() function
7. Enter connection number, name, CMR, LMR in the cells and uncheckthe locked feature from Protection tab from Cell under Format menu
8. Calculate Units = CMR – LMR
9. Amount is obtained by referring to the table as VLOOKUP(D9,Database!A2:B51, 2). The table array should exclude the header.
10. Set the Print area and Page Setup from File menu.
11. Protect the worksheet by choosing Protection from Tools menu andspecify a password.
Result:
The electricity bill is printed using import and protection features
S.K. Vijai Anand cseannauniv.blogspot.com
Date : 12/14/2010Conn. No :Name :
CMR LMR Units Amount (in Rs.)
60700 60480 220 210
Authorized Signatory
CMR-> Current month reading LMR-> Last month reading
Units Rate/unit Units Rate/unit<= 100 0.75 <= 400 3.00<= 200 1.00 <= 500 4.00<= 300 2.00 > 500 5.00
Tamil Nadu Electricity BoardChennai South Circle
Kelambakkam-603 103
S.K. Vijai Anand cseannauniv.blogspot.com
Units Charges10 3520 3530 3540 3550 3560 4270 4980 5690 63
100 70110 80120 90130 100140 110150 120160 130170 140180 150190 160200 170210 190220 210230 230240 250250 270260 290270 310280 330290 350300 370310 400320 430330 460340 490350 520360 550370 580380 610390 640400 670410 710420 750430 790440 830450 870460 910470 950480 990490 1030500 1070
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.1
Ex. No. 3–C PROGRAMMING
C is a powerful, portable and elegantly structured programming language. It combines
features of a high-level language with the elements of an assembler and therefore, suitable for
writing both system software and application packages. It is the most widely used general-
purpose language today. C has been used for implementing systems such as operating
systems, compilers, linkers, word processors and utility packages. It is a robust language
whose rich set of built-in functions and operators can be used to write any complex program.
Programs written in C are fast and efficient.
Turbo C IDE
Turbo C IDE facilitates editing, debugging and execution of applications written in C.
C programs are saved with .c extension. Some of the shortcut keys are:
Ctrl + F1 HelpF2 SaveF3 OpenCopy Ctrl + InsCut Shift + DelPaste Shift + InsClear Ctrl + Del
Alt + F9 CompileCtrl + F9 ExecuteAlt + F5 User ScreenF7 Trace IntoAlt + F3 CloseAlt + X Quit
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.2
Ex. No. 3.1–AREA OF A CIRCLE
Aim
To write a program to compute the area and circumference of a circle.
Algorithm
Step 1 : Start
Step 2 : Define constant pi = 3.14
Step 3 : Read the value of radius
Step 4 : Calculate area using 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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.3
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("\nEnter radius of the circle : ");scanf("%d",&radius);area = pi * radius * radius;circum = 2 * pi * radius;printf("\nArea is %.2f and circumference is
%.2f\n",area,circum);getch();
}
Output
Enter radius of the circle : 8
Area is 200.96 and circumference is 50.24
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.4
Ex. No. 3.2–BIGGEST OF TWO NUMBERS
Aim
To write a program to determine the bigger of two numbers using ternary operator.
Algorithm
Step 1 : Start
Step 2 : Read values of a and b
Step 3 : If a = b then print "Both are equal"
Step 3.1 : Else if a > b then print "A is big"
Step 3.2 : Else print "B is big"
Step 4 : Stop
Flowchart
YN
Y
N
Read a, b
Start
Stop
a=b?
a>b?
Print "Bothare equal"
Print "A isbig"
Print "B isbig"
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.5
Program
/* Biggest of 2 Nos using Ternary Operator */
#include <stdio.h>#include <conio.h>
main(){
int a,b;clrscr();printf("Enter A value : ");scanf("%d",&a);printf("Enter B value : ");scanf("%d",&b);(a==b) ? printf("\nBoth are equal") : a>b ? printf("\nA
is greater") : printf("\nB is greater");getch();
}
Output
Enter A value : -2Enter B value : -5
A is greater
Enter A value : 4Enter B value : 7
B is greater
Enter A value : 11Enter B value : 11
Both are equal
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.6
Ex. No. 3.3–LEAP YEAR
Aim
To write a program to check whether the given year is a leap year.
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"Leap"
Print "NotLeap"
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.7
Program
/* Leap Year */
#include <stdio.h>#include <conio.h>
main(){
int year;clrscr();
printf("\nEnter the year : ");scanf("%d",&year);
if (year%400 == 0)printf("\n%d is a Leap year",year);
else if (year%100 != 0 && year%4 == 0)printf("\n%d is a Leap year",year);
elseprintf("\n%d is not a Leap year",year);
getch();
}
Output
Enter the year : 2000
2000 is a Leap year
Enter the year : 1800
1800 is not a Leap year
Enter the year : 2004
2004 is a Leap year
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.8
Ex. No. 3.4–SIMPLE CALCULATOR
Aim
To write a menu driven calculator program using switch statement.
Algorithm
Step 1 : Start
Step 2 : Display calculator menu options
Step 3 : Read the operator symbol and 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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.9
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"
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.10
Program
/* Simple Calculator */
#include <stdio.h>#include <stdlib.h>#include <conio.h>
main(){
int n1, n2, result;char op;clrscr();printf("\n Simple Calculator\n");printf("\n + Summation");printf("\n - Difference");printf("\n * Product");printf("\n / Quotient");printf("\n % Remainder\n");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("\n%d %c %d = %d", n1, op, n2, result);getch();
}
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.11
Output
Simple Calculator
+ Summation - Difference * Product / Quotient % Remainder
Enter the operator : -Enter operand1 and operand2 : 2 4
2 - 4 = -2
Simple Calculator
+ Summation - Difference * Product / Quotient % Remainder
Enter the operator : *Enter operand1 and operand2 : 3 2
3 * 2 = 6
Simple Calculator
+ Summation - Difference * Product / Quotient % Remainder
Enter the operator : %Enter operand1 and operand2 : 5 2
5 % 2 = 1
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.12
Ex. No. 3.5–BINARY TO DECIMAL
Aim
To write a program to convert binary number to its decimal equivalent using whileloop.
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 : Recompute binary = binary / 10
Step 7 : Increment i by 1
Step 8 : Print decimal
Step 9 : Stop
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.13
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.14
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("\nDecimal Equivalent is %d", dec);getch();
}
Output
Enter a binary number : 1101011
Decimal Equivalent is 107
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.15
Ex. No. 3.6–PRIME NUMBER
Aim
To write a program to check the given number is prime or not 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 to Step 6
Step 5 : Increment i by 1
Step 6 : If flg = 0 then print "Prime"
Step 6.1 : Else print "Not prime"
Step 7 : Stop
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.16
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"
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.17
Program
/* Prime number */
#include <stdio.h>#include <conio.h>
main(){
int i,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("\nThe given number is prime");
elseprintf("\nThe given number is not prime");
getch();}
Output
Enter a number : 27
The given number is not prime
Enter a number : 43
The given number is prime
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.18
Ex. No. 3.7–ARRAY MINIMUM / MAXIMUM
Aim
To write a program to find the largest and smallest of an 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 then max = Ai
Step 7 : If min > Ai then min = Ai
Step 8 : Increment i by 1
Step 9 : Print max, min
Step 10 : Stop
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.19
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.20
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("\nEnter 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("\nMaximum value = %d \n
Minimum value = %d",max,min);getch();
}
Output
Enter number of elements : 6
Enter Array Elements38-711-90
Maximum value = 11Minimum value = -9
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.21
Ex. No. 3.8–MATRIX MULTIPLICATION
Aim
To write a program to perform matrix multiplication based on their dimensions.
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-1 and j = 0 to n-1
Step 6: Set up a loop and read matrix B elements Bij, i = 0 to p-1 and j = 0 to q-1
Step 7 : Initialize i to zero
Step 8 : Initialize j to zero
Step 9 : Assign 0 to Cij
Step 10 : Initialize k to zero
Step 11 : Compute Cij = Cij + Aik * Bkj
Step 12 : Increment k by 1
Repeat steps 11 and 12 until k < n
Step 13 : Increment j by 1
Repeat steps 9–13 until j < q
Step 14 : Increment i by 1
Repeat steps 8–14 until i < 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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.22
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.23
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.24
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;int i, 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("\nMatrix multiplication not possible");getch();exit(0);
}
printf("\nEnter matrix A elements\n");for(i=0; i<r1; i++){
for(j=0; j<c1; j++){
scanf("%d",&a[i][j]);}
}printf("\nEnter 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;
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.25
for(k=0; k<c1; k++){
c[i][j] += a[i][k] * b[k][j];}
}}
printf("\nProduct 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 2
Enter matrix A elements1 1 11 1 1
Enter matrix B elements2 22 22 2
Product matrix C6 66 6
Enter order of matrix A : 3 3Enter order of matrix B : 2 3
Matrix multiplication not possible
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.26
Ex. No. 3.9–ALPHABETICAL ORDER
Aim
To write a program to arrange names in their alphabetic order using bubble sortmethod.
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 name array
Step 10 : Stop
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.27
Flow Chart
Y
N
Read n
namei > namej?
Start
Stop
i = 0 to n–1
Read namei
i
j = i+1 to n–1
Swap stringsnamei , namej
i
i = 0 to n–2
j
i = 0 to n–1
Print namei
i
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.28
Program
/* Sorting strings */
#include <stdio.h>#include <conio.h>#include <string.h>
main(){
char name[20][15], t[15], srch[15];int i,j,n,upper,lower,mid;clrscr();printf("Enter number of students : ");scanf("%d",&n);printf("\nEnter 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();
}
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.29
Output
Enter number of students : 10
Enter student namesRaghuPrabaGopalAnandVenkatKumarSaravanaNareshChristoVasanth
Alphabetical OrderAnandChristoGopalKumarNareshPrabaRaghuSaravanaVasanthVenkat
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.30
Ex. No. 3.10–STRING REVERSE
Aim
To write a program to reverse the given string without using library functions.
Algorithm
Step 1 : Start
Step 2 : Read string str
Step 3 : Assign 0 to len
Step 4 If lenth character '\0' then go to step 5 else step 6
Step 5 : Increment len by 1 and go to step 4
Step 6 : Assign 0 to i and len-1 to j
Step 7: Swap the ith and jth character
Step 8 : Increment i by 1
Step 9 : Decrement j by 1
Repeat steps 7–9 until i < len/2
Step 10 : Print reversed string str
Step 10 : Stop
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.31
Flow Chart
Y
Y
N
Read str
Start
Stop
T = ii = jj = T
Print str
len = 0
lenth char '\0'?
len = len + 1
i = 0j = len - 1
i < len/2?
i = i + 1j = j – 1
N
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.32
Program
/* User-defined String reverse */
#include <stdio.h>#include <conio.h>
main(){
char *str;int i,j,len=0;char t;
clrscr();printf("Enter a String : ");gets(str);
/* String Length */while (str[len] != '\0')
len++;
/* String Reverse */for(i=0, j=len-1; i<len/2; i++, j--){
t = str[i];str[i] = str[j];str[j] = t;
}
printf("\nReversed String : %s",str);getch();
}
Output
Enter a String : SMK Fomra Institute of Tech
Reversed String : hceT fo etutitsnI armoF KMS
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.33
Ex. No. 3.11–SINE SERIES
Aim
To write a program to generate sine series sin(x) =!7!5!3
753 xxxx value 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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.34
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)
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.35
Program
/* Sine series */
#include <stdio.h>#include <math.h>
#define pi 3.14
float sinecalc(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();
}
float sinecalc(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);
}
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.36
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.37
Ex. No. 3.12–RECURSIVE FUNCTION
Aim
To write a program to find 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 parameter n
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)
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.38
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))
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.39
Program
/* Factorial--Recursion */
#include <stdio.h>#include <conio.h>
long factorial(int);
main(){
int n;long int 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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.40
Ex. No. 3.13–PASS BY VALUE & REFERENCE
Aim
To write a program that demonstrates passing parameters to a function by value andreference.
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.41
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)
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.42
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(int a,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;
}
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.43
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.44
Ex. No. 3.14–PAYROLL APPLICATION
Aim
To write a program to print employee payroll of a concern using structure.
Algorithm
Step 1 : Start
Step 2 : Define employee 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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.45
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
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.46
Program
/* Payroll Generation */
#include <stdio.h>#include <conio.h>
struct employee{ int empid; char ename[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;
}
S.K. Vijai Anand cseannauniv.blogspot.com
185151—Computer Practice Laboratory-I
C.47
printf("\n\n\n\t\t\t\tXYZ & Co. Payroll\n\n");for(i=0;i<80;i++)
printf("*");printf("\nEmpId\tName\t\tBasic\t HRA\t DA\t IT\t
Gross\t\tNet Pay\n\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
********************************************************************************
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
P.1
EX. NO. 4–MICROSOFT POWERPOINT
Microsoft PowerPoint is a software application that allows the user to
create presentations. PowerPoint provides a GUI with the help of which we can
create attractive presentations quickly and easily. A slide in PowerPoint is a
combination of images, text, graphics, charts, animations, etc., that is used to
convey meaningful information in a precise and concise way.
Getting Started
To start MS-PowerPoint, type powerpnt from Start Run commandFor creating a new presentation press Ctrl + N.
Presentation Guidelines
1. The first slide should mention the topic clearly and speaker details2. The second slide should be an outline of the presentation
o Only place main points (titles of other slides)o Follow the order of outline
3. Write in point form, not complete sentences.o 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.
S.K. Vijai Anand cseannauniv.blogspot.com
185151— Computer Practice Laboratory–I
P.2
Ex. No. 4.1–MY INSTITUTION
Aim:
To create a presentation that highlights the institution facilities.
Procedure:
Open a blank presentation and design the master slide View MasterSlide Master with background, Fonts, bullets, borders, footers, etc.Choose the appropriate slide layout by using Slide Layout from Formatmenu and type the text in the corresponding places.To add a slide, choose New Slide from Insert menu. The master slidedesign is repainted on the new slideTo insert picture, chart, table, sound or graphic choose the appropriateoptions from Insert menuTo have animation effects use Custom Animation from Slide Showmenu and choose appropriate animation scheme for the slide elementsTo have animation effects between slides choose Slide Transition fromSlide Show menu and choose appropriate effectsAfter completing the presentation choose Save from File menu to savethe contents, usually with extension .pptTo show the presentation, choose Slide Show from View menu.To print multiple slides per page select Handouts in Print Dialog andspecify the number of slides per page.
Result:An effective and elegant presentation about the institution using
PowerPoint is created.
S.K. Vijai Anand cseannauniv.blogspot.com
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
S.K. Vijai Anand cseannauniv.blogspot.com
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
S.K. Vijai Anand cseannauniv.blogspot.com