Vous êtes sur la page 1sur 77

WORD PROCESSING

SPREAD SHEET
C LANGUAGE













C-COMMONLY
O-OPERATING
M-MACHINE
P-PARTICULARLY
U-USED FOR
T-TRADE
E-EDUCATION AND
R-RESEARCH
Prepared by
G.VADIVEL MURUGAN, AP/CSE



GE6161
COMPUTER PRACTICE
LAB-1
FOR FIRST YEAR ALL BRANCHES









DEPARTMENT OF
SCIENCE AND HUMANITIES














SREE SOWDAMBIKA COLLEGE OF ENGINEERING
CHETTIKURICHI, ARUPPUKOTTAI 626 134.










GE6161 COMPUTER PRACTICE LAB-I
(Common to All Branches)



Prepared by Recommended by Approved by



STAFF INCHARGE HEAD OF THE DEPT PRINCIPAL
(G.Vadivelmurugan,AP / CSE)















GE6161 COMPUTER PRACTICE LABORATORY I 0 0 3 2


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 the document
And sheet.
8. Sorting and Import / Export features.

Simple C Programming * 15
9. Data types, Expression Evaluation, Condition Statements.
10. Arrays
11. Structures and Unions
12. Functions

TOTAL: 45 PERIODS

* For programming exercises Flow chart and pseudocode are essential

HARDWARE / SOFTWARE REQUIRED FOR A BATCH OF 30 STUDENTS

Hardware
LAN System with 33 nodes (OR) Standalone PCs 33 Nos.
Printers 3 Nos.
Software
OS Windows / UNIX Clone
Application Package Office suite
Compiler C











GE6161 COMPUTER PRACTICE LAB-1
INDEX
EX.NO
NAME OF THE EXPERIMENT PAGE NO
WORD PROCESSING
1.a. CREATING ADVERTISEMENT 2
1.b CURRICULUM VITAE 3
1.c SCIENTIFIC NOTATIONS 5
2. CREATING TIME TABLE & CONVERSION 6
3.a MAIL MERGE & LETTER PREPARATION 7
3.b VISITING CARD 9
4. DRAWING FLOW CHART 10
VIVA QUESTIONS -WORD PROCESSING 11
SPREAD SHEET
5. SPREAD SHEET CHART (Line, XY, Bar and Pie) 15
6. SPREAD SHEET FORMULA EDITOR 17
7.
INSERT OBJECT, PICTURE, COMMENT AND PROTECT SPREAD
SHEET
19
8. SPREAD SHEET SORTING & IMPORT /EXPORT FEATURES 21
VIVA QUESTIONS-SPREAD SHEET 22
C PROGRAM
9. AREA AND CIRCUMFERENCE OF THE CIRCLE 26
10. ODD OR EVEN 28
11. GREATEST AMONG THREE NUMBER 30
12. QUADRATIC EQUATION 32
13. SIMPLE CALCULATOR 34
14. CONVERT BINARY TO DECIMAL 36
15. PRIME NUMBER 38
16. ARMSTRONG NUMBER 40
17. SUM OF DIGITS ,REVERSE, PALINDROME 42
18. PASCALS TRIANGLE 45
19. SUM SERIES 1+2+3..n 47
20. FIBONACCI SERIES 49
21. COSINE SERIES 51
22. SORTING 53
23. MATRIX MULTIPICATION 56
24. ARRANGINE NAMES IN ALPHABETICAL ORDER 60
25. FACTRORIAL USING RECURSIVE FUNCTION 63
26. STUDENT DATABASE USING STRUCTURE 65
27. EMPLOYEE DATA BASE USING UNION 67
VIVA QUESTION-C PROGRAM 69

1 | P a g e












MI CROSOFT
WORD




2 | P a g e


Ex.No:1a CREATING ADVERTISEMENT
AIM
To prepare an advertisement for a company with some specifications.
Attractive page border.
Use at least one Clip Art.
Design name using Word Art.
Use bullets.
ALGORITHM
Step 1: Open a blank document.
Step 2: Go to Page LayoutPage BordersSelect Attractive Page BorderOk
Step 3: Go to InsertClip ArtSelect Attractive Clip ArtOk.
Step 4: Type a name and selectgo to insertWord ArtSelect a Word Art & click
Step 5: Type a brief company details & Right ClickSelect the Bullets Ok.
Step 6: Save the document.
OUTPUT


ARUPPUKOTTAI
Courses offered:
B.E(CSE)
B.E(ECE)
B.E(EEE)
B.E(CIVIL)
B.E(MECHANICAL)
B.TECH(IT)
M.E(CSE)
ADMISSIONS GOING ON ..

RESULT
Thus the advertisement has been created with some specifications in Microsoft
word successfully and verified.

COLLEGE
CODE:9218


3 | P a g e



Ex.No:1b CURRICULUM VITAE
AIM
To create curriculum vitae (CV) of a B.E graduate with the specification.
Table to show qualifications with heading.
Left & Right margins
Page numbers in the footer on the right side.
Use Watermark.
ALGORITHM
Step 1: Open a blank document.
Step 2: Type a Bio-data briefly then goto Insert TableInsertTableSelect
no of rows & columnsOk for qualifications.
Step 3: Go to Page LayoutMarginsAssignLeft & Right Margins
Step 4: Go to Insert Page NumbersSelect footer on the right sideOk.
Step 5: Go to Page LayoutWatermarkCustomize text as Bio-dataOk.
Step 6: Save the Document.

















4 | P a g e



OUTPUT RESUME
A.Kala Email Id: kaladevi@gmail.com
18/11, South Street
Pudur Mobil No: 9600224325
Tuticorin [dist]
Objective:
To work in a challenging environment where my skills and knowledge will be utilized for
the growth of the organization.
Academic Details:
Course Institution
Board/
University
Year
Marks In
Percentage
B.E., (CSE)
Sree Sowdambika college of
Engineering
Anna
University
2007 89
HSC
S.B.K. Girls Higher
Sec.School
State Board 2003 87
SSLC
S.B.K. Girls Higher
Sec.School
State Board 2001 85
Software Exposure
C, C++, VB and Basics of Java
Personal Profile:
Date of Birth : 03-09-1986
Sex : Female
Nationality : Indian
Marital Status : Single
Languages Known : English, Tamil
Place : Signature
Date : (KALA)

RESULT
Thus the curriculum vitae (CV) has been created with some specifications in Microsoft word
successfully and verified.



5 | P a g e



Ex.No:1c SCIENTIFIC NOTATIONS
AIM
To create a MS-WORD document for the following scientific notation
i. A=


ii.


iii.


iv.


v.

+ 7

4

+ 6

o
ALGORITHM
Step 1: Open a blank document.
Step 2: Go to InsertEquationInsert EquationSelect the specific format.
For eg ,

for

..
Step 3: Select for


Step 4: Select for


Step 5: Save the document.
OUTPUT
i. A=


ii.


iii.


iv.


v.

+ 7

4

+ 6

o
RESULT
Thus the scientific notations has been created in Microsoft word successfully and verified.






6 | P a g e


Ex.No:2 CREATING TIME TABLE & CONVERSION
AIM
To prepare a class timetable using Merge rows, Split row, Insert rows - columns etc and
convert the table into text format.
ALGORITHM
Step1: Open a blank document.
Step 2: InsertTableInsert TableSelect No of rows & columnsOk.
Step 3: Select two cells Right click Merge Cells.
Select one cell Right clickSplit Cell
Select one row Right click InsertInsert One row above or below
Select one column Right click InsertInsert One column left or right
Step 4: Type a Class Timetable with Headings
Step 5: Go to LayoutConvert to textSelect Tabs Ok
Step 6: Save the document as Table and Text Format
OUTPUT CLASS TIME TABLE
Days
&
Periods
I
9.15-
10.00
II
10.00-
10.50
T
E
A

B
R
E
A
K
III
11.05-
11.55
IV
11.55-
12.45

L
U
N
C
H

B
R
E
A
K
V
1.45-
2.30
VI
2.30-
3.10



T
E
A

B
R
E
A
K
VII
3.20-
4.00
VIII
4.00-
4.45
Monday CS 42 CS 46 CS 42 Tutor HS 410 HS 410 CS 45
Tuesday CS 41
CS 47 /
CS 48
CS 47 / CS 48 CS 45 CS 43 MA 44 [TH]
Wednesday CS 46 CS 42 CS 46 MA 44 CS 47 / CS 49
CS 47 /
CS 49
CS 41
Thursday CS 45 MA 44 Lib CS 46 CS 41 MA 44 CS 42 CS 43
Friday MA 44 CS 45 CS 42 CS 45 CS 48 / CS 49
CS 48 /
CS 49
CS 43
RESULT
Thus the class time table has been created & table is converted into text in Microsoft word
successfully and verified.



7 | P a g e


Ex.No:3a
MAIL MERGE & LETTER PREPARATION

AIM
To create a WORD document to call letters for an interview using Mail Merge send to10
candidates

ALGORITHM
STEP 1: Open a blank document
STEP 2: Goto Mailings in Menu Start Mail merge Letters
STEP 3: Type a interview call letter with FROM address and leave some
Space for TO address
STEP 4: Goto Select recipients Type a new list Customize the
Columns Ok
STEP 5: Type a 10 address new some fieldsOksave it
STEP 6: Goto Select recipients Use Existing list open a file Ok
STEP 7: Under the TO Address insert the Merge fields & preview the results
STEP 8: Goto Finish MergeEdit individual Documents All Ok
STEP 9: Save the document












8 | P a g e

OUTPUT




RESULT
Thus the Mail Merge has been created in Microsoft word successfully and verified.












9 | P a g e


Ex.No:3b
VISITING CARD
AIM
To design a visiting card for a Managing Director of a company with the Size of 3.25 inch *
2.5 inch
ALGORITHM
STEP 1: Open a blank document
STEP 2: Goto Page layout Size More Paper Size Assign width 3.25
& height is 2.5 Ok
STEP 3: Type a visiting card with address and some images
STEP 4: Save the document
OUTPUT

S.RAMU GENERAL MANAGER
CISCO Pvt Limited,
10,South street,
Chennai.
Phone No:9876543210

RESULT
Thus the visiting card for a Managing Director of a company has been created in
Microsoft word successfully and verified.










10 | P a g e


Ex.No:4 DRAWING FLOW CHART
AIM
To create a flowchart in WORD to find the greatest of three numbers
ALGORITHM
STEP 1: Open a blank document
STEP 2: Goto Insert shapesFlowchart
STEP 3: Insert the Correct shapes for Input box decision box ,Calculation
box and Output box
STEP 4: Select the box and Right Click Add Text
STEP 5: Use Arrows for Link
STEP 6: Save the document
OUTPUT












RESULT
Thus the flowchart in WORD to find the area and perimeter of a circle has been created in
Microsoft word successfully and verified.


Stop
Read Radius
Area =3.14*r*r
Circum=2*3.14*r

Print Area,Circum
Start


11 | P a g e

VIVA QUESTIONS WITH ANSWERS
WORD PROCESSING
1. What is meant by Word processing?
Word processing is the process of creating, retrieving, and storing and printing text material
in required format
2. What are the features available in word processor?
Editing, formatting, Graphics, Object Linking and Embedding, Spell check,
Tables, Mail merge etc
3. What is meant by viewing a document?
Viewing Ms-Word is the process of displaying the appearance of the document in the
console. The Ms Word provides four ways to view the document .Normal view, online view,
Outline view, Page layout view
4. What is meant by formatting?
Formatting is the process if changing the appearance of the document by changing font
size, type, color and aligning the text in a document.
5. What is meant by a document?
Document is paper containing the information or text or data.
6. What are the types of documents available in MS WORD?
The Ms Word provides four types of documents. They are Blank document, Web pages, E
mail Messags, Templates
7. What is meant by wizard?
Wizard is a predefined program that is very useful to create any type of document in the Ms
Word.
8. What is meant by template?
Template is a special kind of document that produces basic tools for shaping a final
document.
9. What is meant by Dialog box?
A dialog box is a window, which contains Tabs, Options.List or Text boxes and command
buttons that are used to access the particular options.

10. Define Memo document?
Memo document contains the textual information about the memo random and is used to
give memo to the sub ordinates by the superior


12 | P a g e

11. What are the Tabs available in the Page Setup dialog box?
The Page setup Dialog box contains the four Tabs namely, Margins, Paper size, Paper
Source and Layout.
12. Define Fonts?
Fonts are characters, which are typed in the document
13. What is meant by Font Effects?
Font Effects are the elements that are used to enable the appearance of the text in the
document.
14. What are the Font Effects available in MS word?
The M S Word provides eleven types of Font Effects .They are strike through, Double
strikethrough, superscript, subscript shadow, outline, emboss, Engrave, small caps, all caps,
hidden.
15. What is Drop cap?
Drop cap is the process of dropping that first capital letter of a document
16. What is meant by Orientation?
Orientation is the process of directing the text, auto shape .Table cell contain the text or
document either in landscape or portrait orientation
17. How many the scientific notations in MSWord can be applied?
The Scientific notations in MS Word can be applied in two ways as following
1. Using the Subscript or superscript notations
2. Using the Equation Tool bar
18. How many ways the Table can be placed in MS Word?
The table in M S Word can be placed using either of the following
1. Insert Table button
2. Insert Table dialog box
3. Tables and Border Tool bar
4. Convert Table into text
19. What is meant by merging in Table handing?
Merging is the process of combining two or more ceils into a single cell
20. What is meant by sorting?
Sorting is the process of arranging he contents either in ascending order or in descending
order.


13 | P a g e

21. What is mail merge in MS Word?
The mail merge is the process quickly producing g the personalized letters and mailing
labels for ach person in the mailing list of the data source.
22. What are the components available in Sword?
There are three components available in mail mage they are Main document, Data source,
and merged documents
22. What is meant by the Text Wrapping?
Text wrapping is the process of wrapping or aligning the text along the object of the
document.
23. What is an Auto shape?
An auto shape is predefined drawing object in MSWord
25. What are the types of Auto shapes available in MW Word?
The MS Word provides the following types of auto shapes Lines, Basic shapes block
arrows, Flowcharts, stars and Banner and callouts.
26. What is flowchart?
A flowchart is a pictorial diagrammatic representation of the problem
27. What is clip art?
Clip art is a predefined picture which is stored along with the Ms Word
29. What is use of Fax wizard in MS Word?
The MSWord provides the following types of letters such as Fax, Letters and the Wizards
30. What is the use of Mail merging?
The Mailing Merging tool in word allows us to produce the Mailing letters.












14 | P a g e












MI CROSOFT
EXCEL












15 | P a g e


Ex.No:5
SPREAD SHEET CHART (Line, XY, Bar and Pie)
AIM
To create an EXCEL to analyze the marks of the students of a class using various Chart
(Line, XY, Bar and Pie).
ALGORITHM
STEP 1: Open a Microsoft Excel Worksheet.
STEP 2: Place the Cursor on the desired cell and start entering the required
Student details
STEP 3: To find the Total and Average using formula (Total = m1+m2+m3)
Average = (Total / 3)
STEP 4: Select the table and Goto Insert Chart Choose one type of
Chart
STEP 5: Reselect the table again and Insert Chart Choose another
type of Chart like wise do for all charts
STEP 6: Save the Excel Sheet
OUTPUT

NAME M1 M2 M3 TOTAL AVG
ANU 56 7 90 153 51
ABI 45 34 78 157 52.33333
MALA 78 90 65 233 77.66667
ANAND 63 66 86 215 71.66667
AMIR 56 57 78 191 63.66667









16 | P a g e

LINE CHART


PIE CHART


RESULT
Thus the Spreadsheet charts (Line, XY, Bar and Pie) for students marks has been created
successfully and verified.





0
100
200
300
400
500
600
700
800
900
1000
M1 M2 M3 TOTAL AVG
AMIR
ANAND
MALA
ABI
ANU
ANU
M1
M2
M3
TOTAL
AVG


17 | P a g e


Ex.No:6
SPREAD SHEET FORMULA EDITOR
AIM
To create a spreadsheet to calculate HRA ,DA,TA,PF,LIC,Gross Salary ,Net Salary from
the given data
HRA=18% of basic Pay TA=12% of Basic Pay DA=15% of Basic Pay
PF =10% of Basic Pay LIC =7% of Basic Pay Deduction= PF + LIC
Gross Salary = Basic Pay + HRA + DA + TA Net Salary = Gross Salary Deduction
ALGORITHM
STEP 1: Open a Microsoft Excel Worksheet
STEP 2: Type the details about the employees and Basic Salary.
STEP 3: For HRA & DA, move to corresponding row & column and assign the
Formula =18/100* BS (row & column) For DA, move to corresponding row
& column and assign the formula =15/100* BS (row & column)
STEP 4: For TA & PF, move to corresponding row & column and assign the formula
=12/100* BS (row & column) For PF, move to corresponding row & column
And assign the formula =10/100* BS (row & column)
STEP 5: For LIC & GS, move to corresponding row & column and assign the formula
=7/100* BS, For GS, move to corresponding row & column and
assign the formula = Basic Pay + HRA + DA + TA
STEP 6: Likewise for Deduction and Net Salary
STEP 7: Save the ExcelSheet








18 | P a g e


OUTPUT
Spread Sheet using Employee Database

Name Basic HRA TA DA PF GPF LIC GS DD

NS

Santhiya 10000 1800 1500 1200 1000 500 700 14500 2200

12300
Maya 8000 1440 1200 960 800 400 560 11600 1760

9840
Megala 5500 990 825 660 550 275 385 7975 1210

6765
Hari 7800 1404 1170 936 780 390 546 11310 1716

9594
Ashok 8200 1476 1230 984 820 410 574 11890 1804

10086


RESULT
Thus the Spreadsheet to calculate HRA, DA, TA, PF, LIC, Gross Salary, and Net Salary
from the given data has been created successfully and verified.










19 | P a g e


Ex.No:7
INSERT OBJECT, PICTURE, COMMENT AND PROTECT SPREAD SHEET
AIM
To create a spreadsheet insert a Picture, Object, Comment and apply the option of protecting
the document
ALGORITHM
STEP 1: Open a Microsoft Excel Worksheet
STEP 2: Goto Insert Select the Picture Insert and type some Text.
STEP3: Goto Insert Select the Object
STEP4: Goto Review New Comments Type some Comments
STEP 5: Goto Review Protect Sheet Set a Password & Reenter the Password
STEP 6: Goto InsertSmart Art Type text
STEP 6: For Unprotect again Goto Review Unprotect Sheet Type Password
STEP 7: Modify the Worksheet and protect it
STEP 6: Save the ExcelSheet
OUTPUT

Insert Picture

Insert Object [Calendar Control]






Oct 2010 Oct 2010
Sun Mon Tue Wed Thu Fri Sat
26 27 28 29 30 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 1 2 3 4 5 6


20 | P a g e

Insert Comment












Insert Picture Organization Chart:


`



RESULT
Thus the inclusion of object, picture, comments in worksheet and protected successfully and
verified.






Software
Development steps


Analysis


Design


Implementation
Valid user


21 | P a g e


Ex.No:8
SPREAD SHEET SORTING & IMPORT /EXPORT FEATURES
AIM
To create a spreadsheet to sort the names and sort the numbers and convert the numbers
Decimal numbers: 243,46,173,425,625
Binary numbers:-11011, 1110110101, 11001, 11111
ALGORITHM
STEP 1: Open a Microsoft Excel Worksheet.
STEP 2: Type some list of names in randomly
STEP 3: Select the names and Right click SortSelect the names and sort
In Ascending Order ( A to Z)
STEP 4: Select the numbers and Right click SortSelect the numbers and
Sort In Ascending Order (Small to Large)
STEP 5: For Conversion Goto Formula Select More
FunctionsEngineeringSelect DEC2BIN, DEC2HEX,DEC2OCT
and BIN2DEC,BIN2HEX,BIN2OCT etc
STEP 6: Save the ExcelSheet
OUTPUT
Converting Number System
Decimal Binary Octal Hexadecimal
245 11110101 365 F5
122 1111010 172 7A
88 1011000 130 58

(dec2bin) (bin2oct) (oct2hex)
RESULT
Thus the worksheet name & Numbers are sorted and Conversion (Import/Export
Features) has been created successfully and verified.



22 | P a g e

SPREAD SHEET
1. What is spread sheet?
A spread sheet is an Electronic spread sheet is an able of rows man columns into which
data is entered.
2. Specify any five features of Spreadsheet?
Several mathematical, trigonometric, financial and statistical functions are built in. All
complicated calculation can be performed very easily using these functions facilitating rapid
operations.1. The worksheet can be quite big in size and any part of it can be viewed or edited
2. Data can also be viewed in the form of graphs. There are several graphs available and can be
printed.
3. The information entered in a worksheet can be stored in desired format
4. With the electronic worksheet programs, we can easily and quickly produces reports and get
answers to, what if. Questions
3. Define column and row sin worksheet?
Columns: Columns are vertical lines and cells .They are named from A to Z and afterwards AA
toAZ, BA to BZ and so on up to IV.There are 256 column available in the spreadsheet.
Rows: Rows are horizontal lines of cells .A Number identifies each row item from 1 to 65536
.There are 65536 rows available in the spread sheet.
4. Define cell and cell pointer in worksheet?
Cells: A cell in the point where the row and column interact. The width of cell spaces can be
altered to suit the applications
Cell Pointer: It is a highlighted cell boundary that specifies which cell is active at that moment.
5. What is the use of harts in MS Excel?
Charts are visually appealing and make it easy for users to see comparisons, patterns, and
trends in data.
6. What is a chart?
Chart in excel is a graphic representation of worksheet data or visual representation of the
values contained in the worksheet
.
7. What is chart sheet?
A sheet in a work sheet that contains only a chart.It is beneficial to view a chart separate
from worksheets data.
8. What are the types of charts available in MS-Excel?


23 | P a g e

1. Column 2.Bar 3.Line 4.Pie 5.XY (Scatter) 6. Area 7.doughnut 8.Radar 9.Surface 10
.Bubble 11. Stock 12.Cylinder 12.Pyramid
9. What is a formula?
Formulae perform mathematical equations such as multiplication, or they compare
worksheet value or join sheet.Formuals can refer to other cells on the same worksheet. Cells on
other sheets in the same work books.
10. What is the syntax of the Formula in the sheet?
Formulas in Microsoft Excel follow a specific syntax or order that includes and equal sign
(=) followed by the elements to be calculated (the operands).Which is separated by calculation
operators
11. What are the Arithmetic Operators available in Excel?
All arithmetic operators in Excel supports are + (addition),-(subtraction),*(Multiplication), /
(Division), %( Percent), (Exponention)
12. What are the Relational or comparison operator available in MS Excel
The Relational operators the Excel supports are
= (Equal to)
> (greater than)
<(Less than)
>= (greater than or equal to)
<=(less than or equal to)
<> (Not equal to)
13. What is the precedence of Operators?
Precedence is the order of execution of an expression depending on the operators
14. What is meant by Auditing?
The process of examining a worksheet for errors in formula called Auditing.
15. Specify Errors Codes that occurred during the Formulae?
The error code in Excel are #N/A #NULL, #NUM, ####, #VALUE, #NAME, #REF!,
#DIV
16. Specify any four commonly used formula?
a) Calculate sum (=sum(range))
b) Join first and last name (+A5& B5
c) Join a date with text (=Birthday is :&TEXT(F5,dd-mm-yy))
d) Create a total based one condition (+SUMIf (B5:B10,Total sales , A5:A10)
17. What is Function?
A function is a built in mathematical shortcut. We can use a function instead of a very
complex formula to perform a task.


24 | P a g e

18. What are the types of functions available in Excel?
Financial Perform financial calculations and operations
Date and time Calculate Dates ,Times and Days
Math and Trigonometry
Perform simple and complex mathematical
calculations
Statistical Performs statistical operations
Lookup and Reference Find values in arrange of cells
Database Analyze the information in a group of cells
Text Perform operations in characters
Informations Tells us about the type of data in a cell
Logical Determine if a condition is true or false

19. Specify any commonly used functions?
a) POWER: Returns the result of a number raised to a power
b) ROUND: Rounds a number to specified number of digits
C) SUM: adds all the numbers in a range of cells
d) SIN: Returns the sine of the given angle
e) Len: Returns the number of characters in a text string
20. What are the types of Graphics available in Excel?
1. Bitmap type pictures
2. Metafile type pictures
3. Auto shapes










25 | P a g e





C
PROGRAMMI NG















26 | P a g e



Ex.No:9
AREA AND CIRCUMFERENCE OF THE CIRCLE
AIM
To write a C program to find the area and circumference of the circle
ALGORITHM
STEP 1: Start the Program
STEP 2: Input the radius(r) of the Circle.
STEP 3: Find the area and circumference of the circle using the formula
a=3.14*r*r
p=2*3.14*r
STEP 4: Print the a and p
STEP 5: Stop the Program

FLOW CHART














Start
Stop
Read r
a =3.14*r*r
p=2*3.14*r

Print a,p


27 | P a g e



PROGRAM
/*AREA AND CIRCUMFERENCE OF CIRCLE*/
#include<stdio.h>
#include<conio.h>
void main()
{
float r,a,p;
clrscr();
printf("\n Enter the radius of the Circle");
scanf("%f",&r);
a=3.14*r*r;
p=2*3.14*r;
printf("\n Area=%f",a);
printf("\n Circumference=%f",p);
getch();
}

OUTPUT

Enter the radius of the Circle 5
Area=78.500000
Circumference=31.400000

RESULT

Thus the C program to find the area and circumference of the circle has been created
successfully and verified.












28 | P a g e


Ex.No:10
ODD OR EVEN
AIM
To write a C program to find whether given number odd number or even number.
ALGORITHM
STEP 1: Start the Program
STEP 2: Read the value of n
STEP 3: If n mod 2 equals to 0 print odd number
STEP 4: Else print Even Number
STEP 5: Stop the Program
FLOW CHART





NO YES












Start
Read n
If(i%2=
=0)
Odd Number Even Number
Stop


29 | P a g e


PROGRAM
/*ODD OR EVEN*/
#include<stdio.h>
void main()
{
int n;
clrscr();
printf("Enter no");
scanf("%d",&n);
if(n%2==0)
printf("Even Number");
else
printf("Odd number");
getch();
}

OUTPUT

Enter no 4
Even Number
Enter no 5
Odd number

RESULT
Thus the C program to find given number is odd or even has been created successfully and
verified.













30 | P a g e


Ex.No:11
GREATEST AMONG THREE NUMBERS
AIM
To write a C program to find the greatest among three numbers
ALGORITHM
STEP 1: Start the Program
STEP 2: Read the value of a ,b and c
STEP 3: Check condition if a greater than b (a>b) and a greater than c(a>c)
STEP 4: If it is true print a is greatest no
STEP 5: If the condition fails check whether b is greater than c(b>c)
If it is true print b is greatest no
STEP 6: Else print c is greatest no
STEP7:Stop the Program
FLOWCHART



NO YES


YES NO







Start
Read a,b,c
If(a>b
&&a>c)
If(b>c)
Print b Print c
Print a
Stop


31 | P a g e




PROGRAM
/*GREATEST AMONG THREE NUMBERS*/
#include<stdio.h>
void main()
{
int a,b,c;
clrscr();
printf("Enter a,b and c");
scanf("%d%d%d",&a,&b,&c);
if(a>b&&a>c)
printf("a is Greatest no");
else if(b>c)
printf("b is greatest no");
else
printf("c is greatest no");
getch();
}

OUTPUT

Enter a,b and c 4 5 6
c is greatest no

RESULT

Thus the C program to find the greatest among three numbers has been created successfully
and verified.












32 | P a g e


Ex.No:12
QUADTRADIC EQUATION
AIM
To write a C program to find the roots of the Quadratic equation.
ALGORITHM
STEP 1: Start the Program
STEP 2: Read the value of a ,b and c
STEP 3: Find d using the formula ,d=b
2
-4ac
STEP 4: Check if d>0 ,if it is true find the roots using the formula
r1 = ((- b) + sqrt(d)) /( 2*a);
r2 = ((- b )- sqrt(d) / (2*a);
print r1 and r2.
STEP 5: Otherwise print Roots are imaginery
STEP 6:Stop the Program
FLOWCHART




YES NO








Read a,b,c
If(d>
=0)
Print r1,r2
Print imaginary
Stop
Start
d=(b*b)-(4*a*c)
r1 = ((- b) + sqrt(d)) /( 2*a);
r2 = ((- b )- sqrt(d) / (2*a);



33 | P a g e




PROGRAM
/*QUADARATIC EQUATION*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int a,b,c,d;
float r1,r2;
clrscr();
printf("Enter a,b and c");
scanf("%d%d%d",&a,&b,&c);
d=(b*b)-(4*a*c);
if(d>0)
{
r1=((-b)-sqrt(d))/(2*a);
r2=((-b)+sqrt(d))/(2*a);
printf("Roots are %f\t%f\n",r1,r2);
}
else
printf("Roots are imaginery");
getch();
}

OUTPUT

Enter a,b and c1 -5 6
Roots are 2.000000 3.000000

RESULT

Thus the C program to find roots of Quadratic equation has been created successfully and
verified.









34 | P a g e


Ex.No:13
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 res = n1 + n2
STEP 4.1 : Else if operator = then calculate res = n1 n2
STEP 4.2 : Else if operator = * then calculate res= n1 * n2
STEP 4.3 : Else if operator = / then calculate res= n1 / n2
STEP 4.4 : Else if operator = % then calculate res= n1 % n2
STEP 4.5 : Else print "Invalid operator" and go to step 6
STEP 5 : Print res
STEP 6 : Stop
FLOWCHART











+ _ * / %
Other















Start

Display menu
Operator
res=n1+n2 res=n1-n2 res=n1*n2 res=n1/n2 res=n1%n2
Print res
Invalid choice
Stop



35 | P a g e



PROGRAM

/* SIMPLE CALCULATOR */
#include <stdio.h>
void main()
{
int n1, n2, res;
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 : ");
scanf("%c",&op);
printf("Enter operand1 and operand2 : ");
scanf("%d%d",&n1,&n2);
switch (op)
{
case '+': res=n1+n2;
break;
case '-':res=n1-n2;
break;
case '*':res=n1*n2;
break;
case '/':res=n1/n2;
break;
case '%':res=n1%n2;
break;
default: printf("Invalid Choice");
}
printf("\n%d %c %d = %d", n1, op, n2, res);
getch();
}
OUTPUT
Simple Calculator
+ Summation
- Difference
* Product
/ Quotient
% Remainder
Enter the operator : +
Enter operand1 and operand2 : 2 3
2 + 3 = 5

RESULT

Thus the C program for Simple Calculator using switch statement has been created
successfully and verified.




36 | P a g e


Ex.No:14
CONVERT BINARY TO DECIMAL
AIM
To write a C program to convert the binary number into decimal number

ALGORITHM
STEP 1: Start the program.
STEP 2: Enter the binary value
STEP 3: Set a loop.
STEP 4: Convert the binary no into decimal by using statement
Digitbinary no %10
Decimal decimal +(digit <<base)
Basebase+1;
Binary no binaryno /10
STEP 5: After the execution of the loop print the decimal value equivalent
to the entered binary number
STEP 6: Stop the program.

FLOW CHART










No


Yes














Start
Read bnum
Binbnum
Digitbinary no %10Decimal decimal +(digit
<<base) Basebase+1;Binary no binaryno /10

Print bin,decimal
Stop
while(bnum!=0)


37 | P a g e



PROGRAM

/*CONVERT BINARY NO TO DECIMAL NO*/
#include<stdio.h>
#include<conio.h>
void main()
{
int bnum,digit,decimal=0,bin,base=0;
clrscr();
printf("\n Enter the Binary No:");
scanf("%d",&bnum);
bin=bnum;
while(bnum!=0)
{
digit=bnum%10;
decimal=decimal+(digit<<base);
base=base+1;
bnum=bnum/10;
}
printf("\n The Binary %d to Decimal is=%d",bin,decimal);
getch();
}

OUTPUT

Enter the Binary No:100
The Binary 100 to Decimal is=4

RESULT

Thus the C program to convert the binary number into decimal number has been created
successfully and verified.

















38 | P a g e




Ex.No:15
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 f = 0
STEP 4 : Inside for loop, If n is divisible by i then assign 1 to f and go to Step 6
STEP 5 : If f = 0 then print "Prime"
Else print "Not prime"
STEP 6 : Stop
FLOW CHART















Read n
f=0
For(i=2;i<n;i++)
If(n%i==0)
f=1
If(f==0)
Print Prime Print not Prime
Stop
Start


39 | P a g e




PROGRAM

/*PRIME NUMBER*/
#include<stdio.h>
void main()
{
int n,i,f=0;
clrscr();
printf(" Enter Number");
scanf("%d",&n);
for(i=2;i<n;i++)
{
if(n%i==0)
f=1;
}
if(f==0)
printf("%d is prime",n);
else
printf("%d not a prime",n);
getch();
}

OUTPUT

Enter Number 7
7 is prime

RESULT
Thus the C program to check whether given number is prime no or not has been created
successfully and verified.











40 | P a g e


Ex.No:16
ARMSTRONG NUMBER
AIM
To write a program to check the given number is Armstrong number or not using.

ALGORITHM

STEP 1: Start the program.
STEP 2: Enter the number. And assign n1=n,sum-=0
STEP 3: Set a loop upto the number is not equal to zero .
rn%10 sumsum+r*r*r n n/10
STEP 4: After the end of the loop check given numbe(n1)r equal to sum.
STEP 5: If it is equal then print Armstrong no else print not an Armstrong no
STEP 6: Stop the Program.
FLOW CHART

















Yes No











Start
Read n
n1=n,sum=0
r=n%10
sum=sum+r*r*r
n=n/10


Stop
If(n1==sum)
Print Armstrong
no
While(n!=0)
Print not
Armstrong no


41 | P a g e




PROGRAM

/*ARMSTONG NO*/
#include<stdio.h>
void main()
{
int n,n1,r,sum=0;
clrscr();
printf("Enter No:");
scanf("%d",&n);
n1=n;
while(n!=0)
{
r=n%10;
sum=sum+r*r*r;
n=n/10;
}
if(n1==sum)
printf("%d is an Armstrong no",n1);
else
printf("%d is not an Armstrong No",n1);
getch();
}

OUTPUT

Enter No:153
153 is an Armstrong no

RESULT
Thus the C program to check is given number is Armstrong or not has been created
successfully and verified.











42 | P a g e


Ex.No:17
SUM OF DIGITS, REVERSE, PALINDROME
AIM
To write a C program to find the sum & reverse of digits and check is Palindrome or not
ALGORITHM
STEP 1: Start the program.
STEP 2: Enter the number.
STEP 3: Set a loop upto the number is not equal to zero .
Remnum%10 SumSum+rem Rnum rnum *10 +rem Num num/10
STEP 4: After the end of the loop print the sum and reverse no of the digit.
STEP 5: Find whether the reverse no is equal to number then is palindrome otherwise not
an Palindrome
STEP 6: Stop the Program.


































43 | P a g e

FLOWCHART












No

Yes











No



Yes





















Read num
a=num;sum=0 r num=0
rem=num%10
sum=sum+rem
rnum=rnum*10+rem
num=num/10


Stop
Start
Print sum,rnum
If a==r num
Print Palindrome
While(n!=0)
Print not
Palindrome


44 | P a g e

PROGRAM

/*SUM OF DIGITS, REVERSE, PALINDROME*/
#include<stdio.h>
#include<conio.h>
void main()
{
unsigned long int a,num,sum=0,rnum=0,rem;
clrscr();
printf("\n Enter the No:");
scanf("%ld",&num);
a=num;
while(num!=0)
{
rem=num%10;
sum=sum+rem;
rnum=rnum*10+rem;
num=num/10;
}
printf("\n The Sum of Digits %ldis=%ld\n",a,sum);
printf("\n The Reverse %ld is=%ld\n",a,rnum);
if(a==rnum)
printf("\n The Given number is a Palindrome");
else
printf("\n The Given number is not a Palindrome");
getch();
}


OUTPUT

Enter the No:12345
The Sum of Digits 12345is=15
The Reverse 12345 is=54321
The Given number is not a Palindrome

RESULT
Thus the C program to find the sum & reverse of digits and Check is Palindrome or not
was executed successfully.










45 | P a g e


Ex.No:18 PASCALS TRIANGLE
AIM
To write a C program to print Pascals triangle
ALGORITHM
STEP 1: Start the program.
STEP 2: Read input n.
STEP 3: Create the first loop to print n lines.
STEP 4: Check l<= n
STEP 5: Create the second loop to generate 40 spaces initially, then reduce
by 40-3*l equation.
STEP 6: Check i>0
STEP 7: Create the third loop to generate and print digits.
STEP 8: Use m=m*(l-j+1)/j to print digits in each line .
STEP 9: Stop the execution.
FLOWCHART






























Start
Read no
For i=1;i<n+1;i++
temp=i
For j=1;j<n+1;j++
Print
For j=1;j<n+1;j++
Print temp++
Stop


46 | P a g e


PROGRAM
/*PASCALS TRIANGLE*/
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,l,m,n;
clrscr();
printf("How many rows?\n");
scanf("%d",&n);
printf("\n\t\t\t\t Pascals Triangle\n");
m=1;
for(l=0;l<n;l++)
{
for(i=40-3*l;i>0;i--)
printf(" ");
for(j=0;j<=l;j++)
{
if((j==0)||(l==0))
m=1;
else
m=(m*(l-j+1))/j;
printf("%6d",m);
}
printf("\n");
}
getch();
}

OUTPUT

How many rows?
5 Pascals Triangle

1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
RESULT

Thus the C program to print the Pascals triangle has been created successfully and verified.








47 | P a g e


Ex.No:19
SUM SERIES 1+2+3n
AIM
To write a program to calculate the sum of series 1+2+3..n.
ALGORITHM
STEP 1: Start the program.
STEP 2: Enter a number.
STEP 3: Set a loop to find the factorial of the given no using sum=sum+i
STEP 4: Print the sum of the given number.
STEP 5: Stop the program.

FLOWCHART

























Start
Read n
s=0
Stop
For(i=1;i<=n;i++)
s=s+i
Print s


48 | P a g e

PROGRAM
/*SUM SERIES 1+2+3.n*/
#include<stdio.h>
void main()
{
int n,i,s=0;
clrscr();
printf("Enter No");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
s=s+i;
}
printf("The sum of1+2+3 %d is %d",n,s);
getch();
}
OUTPUT
Enter No 5
The sum of 1+2+3..5 is 15
RESULT
Thus the C program to calculate sum series has been created successfully and
verified.


















49 | P a g e


Ex.No:20
FIBONACCI SERIES
AIM
To write a program to find the Fibonacci series of the given number
ALGORITHM
STEP 1: Start the program.
STEP 2: Enter the number.
STEP 3: Check the number whether the number is zero or not.
If zero print zero value.If not zero go further.
STEP 4: Set a loop upto the given number.
STEP 5: fib=fib+a; a=b; b=c;
STEP 6: Every increment in the loop prints the value of fib.
STEP 7: After the execution of the loop stops the program.
FLOWCHART


























Start
Read n
f1=0,f2=1
Stop
For(i=1;i<=n;i++)
Print f1,f2
f=f1+f2
Print f

f1=f2,f2=f


50 | P a g e


PROGRAM
/*FIBONACCI SERIES*/
#include<stdio.h>
void main()
{
int n,i,f1=0,f2=1,f;
clrscr();
printf("Enter No");
scanf("%d",&n);
printf(Fibonacci Series);
printf("%d%d",f1,f2);
for(i=2;i<n;i++)
{
f=f1+f2;
printf("%d",f);
f1=f2;
f2=f;
}
getch();
}

OUTPUT
Enter No 6
Fibonacci series 0 1 1 2 3 5

RESULT
Thus the C program to find Fibonacci series has been created successfully and verified.















51 | P a g e


Ex.No:21 COSINE SERIES
AIM
To write a C program to find the cosine series of the value x

ALGORITHM
STEP 1: Start the program.
STEP 2: Enter the value of X.
STEP 3: Convert X into radian.
STEP 4: Set a loop.
STEP 5: Find the value of Cosine using the formula
Temp=temp*pow((double)(-1),(double)(2*i-1))*x*x/(2*i*(2*i-1))
Sum=sum+temp
STEP 6: After the execution of the loop print the Cosine value.
STEP 7: Stop the program.

FLOW CHART
































Read x
X=X*3.14/180
Temp =1 sum=1,a=x
For i=1;i<n+1;i++
temp=temp*pow((double)(-1),(double)(2*i-
1))*x*x/(2*i*(2*i-1))

Sum=Sum+temp
Print Sum
Stop
Start


52 | P a g e


PROGRAM

/* COSINE SERIES*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float x,a,sum,temp;
int i,no=20,mul;
clrscr();
printf("\n Enter the value of x ");
scanf("%f",&x);
a=x;
x=x*3.14/180;
temp=1;sum=1;
for(i=1;i<no+1;i++)
{
temp=temp*pow((double)(-1),(double)(2*i-1))*x*x/(2*i*(2*i-1));
sum=sum+temp;
}
printf(" \n The cosine value of %f is %f",a,sum);
getch();
}

OUTPUT

Enter the value of x 45
The cosine value of 45.000000 is 0.707176

RESULT

Thus the C program to find the cosine series was created successfully and verified.















53 | P a g e


Ex.No:22

SORTING
AIM
To write a C program to perform sorting the array elements.

ALGORITHM

STEP 1: Start the program.
STEP 2: Enter the size n
STEP 3: Enter the elements of the matrix using for loop
STEP 4: Inside for loop (i=0 to n-1)set another for loop (j=1to n-1)
and check condition if (a[i]> a[j])
STEP 5: If it is true swap the two values using temporary variable (temp)
STEP 6: Repeat the steps until the condition false
STEP 7: Print the elements of the matrix in matrix form.
STEP 8: Stop the program.





























54 | P a g e


FLOWCHART





























Start
Read no
For i=1;i<n+1;i++
Read a[i]
For i=1;i<n+1;i++
For i=1;i<n+1;i++
if(a[i]>
a[j]
temp=a[i]
a[i]=a[j]
a[j]=temp
For i=1;i<n+1;i++
Print a[i]
Stop


55 | P a g e



PROGRAM

/*SORTING*/
#include<stdio.h>
void main()
{
int n,a[10],i,j,temp;
clrscr();
printf("Enter size");
scanf("%d",&n);
printf("Enter Elements");
for(i=0;i<n;i++)
scanf("%d",&a[i]);
for(i=0;i<n;i++)
{
for(j=0;j<n-1;j++)
{
if(a[i]<a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("Sorted Order");
for(i=0;i<n;i++)
printf("%d\t",a[i]);
getch();
}

OUTPUT

Enter size4
Enter Elements 9 8 7 2
Sorted Order 2 7 8 9

RESULT

Thus the C program to print array elements in sorted order has been created successfully
and verified.









56 | P a g e

Ex.No:23
MATRIX MULTIPLICATION

AIM
To write a C program to perform Matrix Multiplication.

ALGORITHM

STEP 1: Start the program.
STEP 2: Read the row and column of the A matrix.
STEP 3: Read the row and column of the B matrix.
STEP 4: Using for loop read matrix value a[i][j]
STEP 5: Using for loop read matrix value b[i][j]
STEP 6: Set a loop to calculate matrix multiplication
STEP 7: c[i][j]=0
C[i][j]+=a[i][k]*b[k][j]
STEP 8: Print the resultant matrix using for loop
STEP 9: Stop the program.






























57 | P a g e


FLOWCHART















































Start
Read p,q
Read r,s
For j=0;j<n;j++
Read a[i][j]
For i=0;i<n;i++
For i=0;i<n;i++
For j=0;j<n;j++
For i=0;i<n;i++
For j=0;j<n;j++
For k=0;k<n;i++
For i=0;i<n;i++
For j=0;j<n;i++
Print c[i][j]
Stop
C[i][j]=0
C[i][j]+=a[i][k]*b[k][j]
Read b[i][j]


58 | P a g e


PROGRAM
/*MATRIX MULTIPICATION*/
#include<stdio.h>
#include<conio.h>
void main()
{
int a[25][25],b[25][25],c[25][25],i,j,k,r,s;
int m,n;
clrscr();
printf(" Enter the row and columns of A matrix.......");
scanf("%d%d",&m,&n);
printf("Enter the row and columns of B matrix,,,,,,,,,,");
scanf("%d%d",&r,&s);
if(m!=r)
printf("\n The matrix cannot multipled");
else
{
printf("\n Enter the elements of A matrix");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("\t%d",&a[i][j]);
}
printf("\n Enter the elements of B matrix");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("\t%d",&b[i][j]);
}
printf("\n the elements of A matrix");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("\t%d",a[i][j]);
}
printf("\n the elements of B matrix");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("\t%d",b[i][j]);
}
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
{


59 | P a g e

c[i][j]=0;
for(k=0;k<m;k++)
c[i][j]=c[i][j]+a[i][k]*b[k][j];
} } }
printf("The multiplication of two matrixes");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("\t%d",c[i][j]);
} getch();
}

OUTPUT
Enter the row and columns of A matrix.......3 3
Enter the row and columns of B matrix,,,,,,,,,,3 3
Enter the elements of A matrix1 2 3 4 5 6 7 8 9
Enter the elements of B matrix1 2 3 4 5 6 7 8 9
the elements of A matrix
1 2 3
4 5 6
7 8 9
the elements of B matrix
1 2 3
4 5 6
7 8 9
The multiplication of two matrixes
30 36 42
66 81 96
102 126 150

RESULT

Thus the C program to perform Matrix Multiplication has been created successfully and
verified.
















60 | P a g e


Ex.No:24
ARRANGE NAMES IN ALPHABETICAL ORDER
AIM
To write a C program to arrange names in alphabetical order
ALGORITHM .
STEP 1: Start the Program
STEP 2: Read input n.
STEP 3: Get the names using for loop.
STEP 4: Initialize i to 0, ji+1.
STEP 5: Compare the names by using strcmp function.
STEP 6: Print the names in alphabetical order.
STEP 7: Stop the execution.





















61 | P a g e


FLOWCHART




























Start
Read n
For i=0;i<n;i++
Read names[i]
For i=0;i<n-1;i++
For i=1+1;j<n;i++
if
strcmp(names
[i],names[j])>
0
strcpy(names[i],temp)
strcpy(names[i],names[j])
strcpy(names[j],temp)
For i=1;i<n+1;i++
Print names[i
Stop


62 | P a g e

PROGRAM
/*ARRANGE NAMES IN ALPHABETICAL ORDER*/
#include<stdio.h>
#include<conio.h>
#include<string.h>
main()
{
char names[50][20],temp[20];
int n,i,j;
clrscr();
printf("\n how many names?");
scanf("%d", &n);
printf("\n Enter the %d names one by one and\n ",n);
for(i=0;i<n;i++)
scanf("%s",names[i]);
for(i=0;i<n-1;i++)
for(j=i+1;j<n;j++)
if(strcmp(names[i],names[j])>0)
{
strcpy(temp,names[i]);
strcpy(names[i],names[j]);
strcpy(names[j],temp);
}
printf("\n names in alphabetical order");
for(i=0;i<n;i++)
printf("\n%s",names[i]);
getch();
}
OUTPUT
How many names? 4
Enter the 4 names one by one and
priya
anu
devi
sathiya
names in alphabetical order
anu
devi
priya
sathiya
RESULT
Thus the C program to arrange names in alphabetical order has been created successfully and
verified.






63 | P a g e


Ex.No:25
FACTRORIAL USING RECURSIVE FUNCTION
AIM
To write a C program to find factorial of given no using recursive function

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)

FLOWCHART























NO


YES







Start
Read n
f=factorial(n)
Print f
Stop
factorial(n)
If a<=1
return 1
return(n*factorial(n-1))


64 | P a g e


PROGRAM

/*FACTORIAL USING RECURSIVE FUNCTION
#include<stdio.h>
int factorial(int n);
void main()
{
int n,f;
clrscr();
printf("Enter No");
scanf("%d",&n);
f=factorial(n);
printf("The factorial of %d is %d",n,f);
getch();
}
int factorial(int n)
{
if(n<=1)
return 1;
else
return (n*factorial(n-1));
}

OUTPUT
Enter No 6
The factorial of 6 is 720

RESULT

Thus the C program to find factorial of n number using recursive function has been created
successfully and verified.


























65 | P a g e


Ex.No:26
STUDENT DATABASE USING STRUCTURES
AIM
To write a C program to print the student database using structures.

ALGORITHM

STEP 1: Start the program.
STEP 2: Struct std
Rno,marks:integer
Name[10]:character
End Struct
STEP 3: Read total number of students n.
STEP 4: Read s[i].rno.s[i].name,s[i].marks
STEP 5: Print s[i].rno,s[i].name,s[i].marks
STEP 6: Stop the program.
FLOWCHART

































Start
struct student
rno:int
name[2]:char
marks:integer

For i=1;i<n+1;i++
Read
s[i].rno,s[i].name,s[i].marks
For i=1;i<n+1;i++
Print
s[i].rno,s[i].name,s[i].marks
Stop


66 | P a g e


PROGRAM
/*STUDENT DATABASE USING STRUCTURE*/
#include<stdio.h>
#include<conio.h>
struct student
{
int rno;
char name[10];
int marks;
}s[10];
void main()
{
int i,n;
clrscr();
printf("Enter Upper limit:");
scanf("%d",&n);
printf("Enter student details:\n");
printf("Enter the RollNo,Name and Mark:\n");
for(i=1;i<=n;i++)
scanf("%d%s%d",&s[i].rno,s[i].name,&s[i].marks);
printf("\n");
printf("student details are \n\n");
printf("Rollno \t Name\t\tMarks\n");
for(i=1;i<=n;i++)
printf("%d\t\t%s\t\t%d\n",s[i].rno,s[i].name,s[i].marks);
getch();
}
OUTPUT

Enter Upper limit:2
Enter student details:
Enter the RollNo,Name and Mark:
1 Raj 80
2 Ram 90
Student details are

Roll no Name Marks
1 Raj 80
2 Ram 90
RESULT

Thus the program to print the mark sheet of n students using structures has been created
successfully.














67 | P a g e


Ex.No:27
EMPLOYEE DATABASE USING UNION
AIM
To write a C program to print the employee database using union.

ALGORITHM

STEP 1: Start the Program.
STEP 2: Now define a Union emp before the main function.
STEP 3: Inside union,Declare the member name ,desg as char type andsalary,eno as
integer datatype
STEP4 : Declare the variable n as integer data type with in main().
STEP 5: Get the value of name, desg and no from the user
STEP 6:.Dispaly the value of e.name and e,desg
STEP7 : Assign the value e.salary=9000,e.eno=1
STEP8 :Display the value of e.salary, e.eno
STEP9: Stop the Program.
FLOWCHART































Start
union emp
name[20]:char
desg[20]:char
salary:int
eno:int

Print employee details
Read e.name,e.desg
Print employee details
Stop
Print employee details
e.salary=1
e.eno=1


68 | P a g e



PROGRAM

/*EMPLOYEE DETAILS USING UNION*/
#include<stdio.h>
union emp
{
char name[20];
char desg[20];
int salary;
int eno;
}e;
void main()
{
clrscr();
printf("EMPLOYEE DETAILS USING UNION\n");
printf("ENTER EMPLOYEE NAME");
scanf("%s",e.name);
printf("ENTER EMPLOYEE DESIGNATION");
scanf("%s",e.desg);
printf("*****EMPLOYEE DETAILS*****\n");
printf("NAME:%s\n",e.name);
printf("DESIGNATION:%s\n",e.desg);
e.salary=9000;
e.eno=1;
printf("SALARY:%d\n",e.salary);
printf("EMP NO:%d\n",e.eno);
getch();
}
OUTPUT

EMPLOYEE DETAILS USING UNION
ENTER EMPLOYEE NAME Velavan
ENTER EMPLOYEE DESIGNATION Professor
*****EMPLOYEE DETAILS*****
NAME:Professor
DESIGNATION:Professor
SALARY:1
EMP NO:1
RESULT

Thus the C program for employee database using union has been created successfully.










69 | P a g e

VIVA QUESTIONS WITH ANSWERS
C PROGRAM
1. Who developed the C language?
C is one of the most popular programming language, it was developed by Dennis Ritchie
at AT & Ts Bell Laboratories.

2. Why c language is called as c language?
Because it's developed after the B language. the B language has been developed also in Bell
Labs by Key Thompson. The C itself is improvement on the B language

3. List out some of the rules used for C programming.
All statements should be written in lower case letters. Upper case letters are only for
symbolic constants.
Blank spaces may be inserted between the words. This improves the readability of
statements.
It is a free-form language; we can write statements anywhere between { and }.
Opening and closing braces should be balanced.

4. What are Keywords?
Keywords are certain reserved words that have standard and pre-defined meaning in
C. These keywords can be used only for their intended purpose.

5. What do you mean by variables in C?
A variable is a data name used for storing a data value.
Can be assigned different values at different times during program execution.
Can be chosen by programmer in a meaningful way so as to reflect its function in the
program.
Some examples are: Sum ,percent_1 ,class_total

6. Why header files are included in C programming?
This section is used to include the function definitions used in the program.
Each header file has h extension and include using # include directive at the
beginning of a program.

7. List the header files in C language.
<stdio.h> contains standard I/O functions
<ctype.h> contains character handling functions
<stdlib.h> contains general utility functions
<string.h> contains string manipulation functions
<math.h> contains mathematical functions
<time.h> contains time manipulation functions

8. Write short notes about main ( ) function in C program.
Every C program must have main ( ) function.
All functions in C, has to end with ( ) parenthesis.
It is a starting point of all C programs.
The program execution starts from the opening brace { and ends with closing brace
}, within which executable part of the program exists.

9. What are the different data types available in C?
int - 2 Bytes
char - 1 Byte
float - 4 Bytes
long int - 4 Bytes
double - 8 Bytes



70 | P a g e

10. List the types of operators.
Operators Types
Symbolic Representation

Arithmetic operators = , - , * , / and %
Logical operators && , || and !
Assignment operators = , + = , - = , * = , / = , ^ = , ; = , & =
Comma operator ,
Relational operators > , < , == , >=, <= and !=
Increment and Decrement operators ++ and
Bitwise operators & , | , ^ , >> , << , and ~
Conditional operator ? :

11. What are the types of I/O statements available in C?
There are two types of I/O statements available in C.
Formatted I/O Statements
Unformatted I/O Statements

12. What is meant by Control String in Input/Output Statements?
Control Statements contains the format code characters, specifies the type of data that the
user accessed within the Input/output statements.

13. What is an Operator and Operand?
An operator is a symbol that specifies an operation to be performed on operands.
Example: *, +, -, / are called arithmetic operators.
The data items that operators act upon are called operands.
Example: a+b; In this statement a and b are called operands.

14. What is a Modulo Operator?
` % is modulo operator. It gives the remainder of an integer division
Example: a=17, b=6. Then c=%b gives 5.

15. What is the difference between ++a and a++?
++a means do the increment before the operation (pre increment)
a++ means do the increment after the operation (post increment)
Example:
a=5;
x=a++; /* assign x=5*/
y=a; /*now y assigns y=6*/
x=++a; /*assigns x=7*/
16. Compare switch ( ) and nested if statement.

switch( ) case nested if
Test for equality i.e., only constant
values are applicable.
It can equate relational (or) logical expressions.
No two case statements in same switch.
Same conditions may be repeated for a number
of times.
Character constants are automatically
converted to integers.
Character constants are automatically
converted to integers.
In switch( ) case statement nested if
can be used.
In nested if statement switch case can
be used.







71 | P a g e


17. Distinguish between while..do and do..while statement in C. (JAN 2009)
While DO..while
(i) Executes the statements within the
while block if only the condition is true.
i) Executes the statements within the while
block at least once.
(ii) The condition is checked at the
starting of the loop
(ii) The condition is checked at the end of the
loop

18.Give the syntax for the for loop statement
for (Initialize counter; Test condition; Increment / Decrement)
{
statements;
}
Initialization counter sets the loop to an initial value. This statement is executed only once.
The test condition is a relational expression that determines the number of iterations
desired or it determines when to exit from the loop. The for loop continues to
execute as long as conditional test is satisfied. When condition becomes false, the control of
program exists the body of the for loop and executes next statement after the body of the
loop.

19. What is an array?
An array is a group of similar data types stored under a common name.
Example:int a[10];
Here a[10] is an array with 10 values.
20. What are the main elements of an array declaration?
Array name
Type and
Size

22. What will happen when you access the array more than its dimension?
When you access the array more than its dimensions some garbage value is stored in the
array.

23. What are the types of Arrays?
1. One-Dimensional Array
2. Two-Dimensional Array
3. Multi-Dimensional Array

24. What is meant by a function?
Function is a set of instructions used to perform particular task.

25. Differentiate library functions and User-defined functions.
Library Functions User-defined Functions
a) Library functions are pre-defined set of
functions that are defined in C
libraries
a) The User-defined functions are the
functions defined by the user
according to his/her requirement.
b) User can only use the function but
cannot change (or) modify this
function.
b) User can use this type of function.
User can also modify this function.

26. What are the steps in writing a function in a program?
a) Function Declaration (Prototype declaration):
Every user-defined functions has to be declared before the main().
b) Function Callings:
The user-defined functions can be called inside any functions like main(),
user-defined function, etc.


72 | P a g e

c) Function Definition:
The function definition block is used to define the user-defined functions with
statements.

27. What is a use of return Keyword?
The return Keyword is used only when a function returns a value

28. Classify the functions based on arguments and return values.
Depending on the arguments and return values, functions are classified into four types.
a) Function without arguments and return values.
b) Function with arguments but without return values.
c) Function without arguments but with return values.
d) Function with arguments and return values.

29. How can you return more than one value from a function?
A Function returns only one value. By using pointer we can return more than one
value.

30. Distinguish between Call by value Call by reference
Call by value Call by reference
a) In call by value, the value of actual
agreements is passed to the formal
arguments and the operation is done on
formal arguments.

a) In call by reference, the address of
actual argument values is passed to
formal argument values
b) Formal arguments values are
photocopies of actual arguments
values.

b) Formal arguments values are pointers
to the actual argument values
c) Changes made in formal arguments
valued do not affect the actual
arguments values.
c) Since Address is passed, the changes
made in the both arguments values are
permanent.


31. Is it possible to place a return statement anywhere in C program?
Yes. The return statement can occur anywhere.

32. What is meant by Recursive function?
If a function calls itself again and again, then that function is called Recursive
function.

33. What is a String?
String is an array of characters.

34. What is the use of \0 character?
When declaring character arrays (strings), \0 (NULL) character is automatically added at
end. The \0 character acts as an end of character array.

35.Why we dont use the symbol & symbol, while reading a String through scanf()?
The & is not used in scanf() while reading string, because the character variable
itself specifies as a base address.
Example: name, &name[0] both the declarations are same.

36.List out some string standard function?
Standard String Functions:
strlen( )


73 | P a g e

strcpy( )
strncpy( )
stricmp( )
strcmp( )
strncmp( )
strcat( )
strrev( )

37. What is a Structure?
Structure is a group name in which dissimilar datas are grouped together

38. What is Union?
Union is a group name used to define dissimilar data types. The union occupies
only the maximum byte of the data type. If you declare integer and character, then the
union occupies only 2 bytes, whereas structure occupies only 3 bytes.

39.Compare arrays and structures.
Comparison of arrays and structures is as follows.
Arrays Structures
An array is a collection of data items of
same data type.
A structure is a collection of data items of
different data types.
Arrays can only be declared Structures can be declared and defined
There is no keyword for arrays. The keyword for structures is struct.
An array name represents the address of the
starting element.
A structure name is known as tag. It is a
shorthand notation of the declaration.
An array cannot have bit fields. A structure may contain bit fields.


40. Compare structures and unions
Structure Union
Every member has its own memory All members use the same memory
All members occupy separate memory
location, hence different interpretations of
the same memory location are not possible.
Different interpretations for the
same memory location are possible.


41. What are the types of errors occurred in C program?
1. Syntax errors
2. Runtime errors
3. Logical errors
4. Latent errors
42. Specify any five syntax error messages.
Missing semicolon
Missing braces
Missing quotes
Improper comment characters
Undeclared variables

Vous aimerez peut-être aussi