record note book - web viewto manipulate the text document with scientific notation using ms-word....

104
CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING GE6161 COMPUTER PRACTICES LAB L A B M A N U A L 1

Upload: duongque

Post on 02-Feb-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY

DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

GE6161 COMPUTER PRACTICES LAB

L A B M A N U A L

1

Page 2: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY

RECORD NOTE BOOK

Register Number:

Certified that this is the bonafide record of work done by

Mr./Ms._____________________________ of the______________ Semester

Branch during the year 2013 – 2014 in the GE6161 - COMPUTER PRACTICES

LABORATORY.

Staff in-charge Head of the Department

Submitted for the University PracticalExamination on …………………..

Internal Examiner External Examiner

GE6161 - COMPUTER PRACTICES LABORATORY

2

Page 3: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

I Year - I SemesterTABLE OF CONTENTS

Ex. No. Concept Date Exercise Page No Marks Sign

1.a MS-Word Document Creation

1.b MS-Word Text manipulation with scientific notations

1.c MS-Word Advertisement

1.d MS-Word Mail merging

1.e MS-Word Importing images

1.f MS-Word Creation of table

1.g MS-Word Drawing- flow chart

2.a MS-Excel Chart - Line, XY, Bar and Pie

2.b MS-Excel Formula- formula editor

2.c MS-ExcelSpread sheet - inclusion of object, Picture and graphics, protecting the document and sheet

2.d MS-Excel Spread sheet to analyze the marks of the students

2.eMS-Excel

Sorting and Importing

3 MS-Power Point

Presentation for the department with power point using animation, design templates and effective presentation

4

Datatypes, Expression Evaluation, Condition

simple menu driven calculator program using switch statement

5 Statements, To Find Age in terms of years, months and days

3

Page 4: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex. No. Concept Date Exercise Page No Marks Sign

operators and

expressions

6 IO formatting Multiplication table for the given number

7.aDecision making Palindrome

7.bDecision making Prime Number

8 Looping Fibonacci series

9 Arrays Largest and Smallest number in a given array

10 Arrays Ascending /descending order

11 Arrays Reverse the elements

12.a Arrays Matrix addition

12.b Arrays Matrix Multiplication

13.a String manipulation

String Copy

13.b String manipulation

String Length

13.c String manipulation

String Concatenation

13.d String manipulation

String Comparison

13.e String String Reverse

4

Page 5: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex. No. Concept Date Exercise Page No Marks Sign

Manipulation

14String

manipulation Alphabetical order

15 Functions Sequential search

16 Recursion Factorial of a number using recursion

17.aScientific

Calculation Trigonometric series – cosine

17.bScientific

Calculation Trigonometric series - sine

18 Structures Mark sheet of ‘n’ students using structures

19 Pointers Print the element of an array using pointers

20 Unions Demonstration of Union

5

Page 6: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

MS-WORD

6

Page 7: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:1.a DOCUMENT CREATION

Aim:To create a Bio-data in ms-word

Procedure:Step 1: select startprogram Microsoft word 2007Step 2: click Page LayoutSize to setup the page sizeStep 3: Type the personal bio-data Step 4: Type the information and choose the required font size and also perform other formatting Step 5: Click FilesaveStep 6: Close the document after saving.

Bio data

Name :G.KannanFather name :P.GovindarajanAge : 18Gender : MaleQualification : H.Sc.Address : New Street

Trichirapalli-621 105Nationality : IndianLanguage known : Tamil,English,Telugu and Hindi

Result: Thus Bio-data in word is created and verified.

7

Page 8: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:1.b TEXT MANIPULATION WITH SCIENTIFIC NOTATIONS

Aim: To manipulate the text document with scientific notation using ms-word

Procedure:Step 1: select startprogram Microsoft wordStep 2: click Filenew and entries are typedStep 3: In formula we have to use subscript and superscript numbers and symbols also.Step 4: To use the super script and Subscript HomeFontX2 X2

(ctrl+ shift + + for superscript and ctrl + = for subscript) may be used .Step 5: To use the symbol InsertSymbolsStep 6: After editing save the document.

Scientific Notations :

(A+B) 2 = A2 +B2 +2ABE=MC2

2Na(OH)2+Cl22NaCl+2H2O+O2↑0.00988= 9.88*10-3

Result: Thus the text is manipulated with scientific notation using ms-word.

8

Page 9: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:1.c ADVERTISEMENT

Aim: To create an advertisement in ms-word

procedure:Step 1: select startprogram Microsoft wordStep 2: Click Page Layoutsize to setup the page sizeStep 3: Click insertShapes.Step 4: Select “rectangle from the auto shapes drag and drop in the windowStep 5: type the information and choose the required font size and also perform other formatting

Result : Thus an advertisement in word is created and verified.

9

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY

Admissions Open 2010-2011

COURSES OFFERED:

1. B.E. COMPUTER SCIENCE AND ENGG.2. B.E. MECHANICAL ENGG3. B.E. ELECTRICAL AND ELECTRONICS ENGG.4. B.E. ELECTRICAL AND ELECTRONICS ENGG.5. B.E. CIVIL ENGG.

Page 10: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:1.d MAIL MERGE

Aim: To perform mail merge operation for sending application To many companies

Procedure:Step1: start a new document step2: click MailingsStart Mail MergeStep by Step MM Wizardstep3: In step 1 of 6 select document type as “letters”step4: In step 1 of 6, clicknext starting document, step5: In step 2 of 6, clickuse the current documentstep6: In step 3 of 6, click type a new list click create new address list dialog box appears.Step7: Using customize option we can add, delete or rename the fields names. Step8: Clickclose save the document in save address list dialog boxStep9: In step 4of 6 click .write your letter click Address BlockGreeting Block next, preview your letterStep 10: In Step 5of 6 click preview the merged data in the letter RecipientStep 11: In Step 6 of 6 complete the merge and take the printout.

Step by Step MM Wizard:

Step 1:

10

Page 11: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step 2:

Step3:

11

Page 12: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step3.1:

Step 3.2

12

Page 13: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step 3.3:

Step 4:

Step 5:

13

Page 14: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step 6:

Result: Thus the mail merge is performed for sending call letter to many candidates and verified

Ex.No:1.e IMPORTING IMAGES

14

Page 15: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Aim:To import an image in ms-word.

Procedure:Step 1: Select StartProgram Microsoft wordStep 2: Click Page LayoutPage Setup to setup the page sizeStep 3: Click InsertPicture From File option.Step 4: Select a file picture to insert.Step 5: Click insert in dialog box

IMPORTING IMAGES IN MS WORD

Step 1

Step 2:

15

Page 16: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step 3

Result:

Thus an image in word is imported and verified.

16

Page 17: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:1.f CREATION OF TABLE

Aim:To create the table and format the created table & convert those table into text format using ms-word

Procedure:Step 1: Select startprogramMicrosoft wordStep 2: Click insert menu, select tableselect the no. of columns and rows from the matrix (or)

select insert tableEnter the number of columns & rows in text box -- select ok buttonStep 4: Click the table merge cells now the selected cells are merged into large cellsStep5: AUTO FORMATTING

a. select the table in the document in the topb. dialog box appears, choose the required formatclick okc. specified format is applied To the table

Step6: CONVERTING THE TABLE TO TEXTa. select tableTable ToolsLayoutdataTable to Textselect the tab optionb. the table information is converted into text

Step 7: CONVERTING THE TEXT TO TABLEa. select tableconvert text To table optionb. the text information is converted into table

TABLE CREATION

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGYROLL NO NAME MARK1 MARK2 MARK3901 Arun 76 74 65902 Saranraj 87 68 88903 David 79 92 81904 Suguna 82 69 85

AUTO FORMATTING TABLESCHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY

ROLL NO NAME MARK1 MARK2 MARK3901 Arun 76 74 65902 Saranraj 87 68 88903 David 79 92 81904 Suguna 82 69 85

17

Page 18: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

CONVERTING TABLE TO TEXT

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGY ROLL NO NAME MARK1 MARK2 MARK3901 Arun 76 74 65902 Saranraj 87 68 88903 David 79 92 81904 Suguna 82 69 85

CONVERTING TEXT TO TABLE

CHETTINAD COLLEGE OF ENGINEERING & TECHNOLOGYROLL NO NAME MARK1 MARK2 MARK3901 Arun 76 74 65902 Saranraj 87 68 88903 David 79 92 81904 Suguna 82 69 85

Result:Thus the table is created, formatted &conversion is performed.

18

Page 19: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.NO:1.g DRAWING - FLOW CHART

Aim:

To prepare a flow chart using ms-word

Procedure:

Step1: choose shapes option in the insert menu of Tools bar.

Step2: choose the appropriate flow chart symbol then drag the symbol in the document.

Step3: type the text in the symbol, by right clicking the mouse, choose add text

Step4: using the arrow button drawing Tool bar, draw the lines connecting the different symbol.

Step5: select all the lines and symbols right click and go grouping finally save the file

19

Page 20: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

DRAWING FLOWCHARTS

Result: Thus the flow chart is prepared using ms-word

20

FALSE FALSE

START

READ A,B,C

ISA>B

ISA>C

IS B>C

PRINT “C IS GREATER”

PRINT “A IS GREATER”

PRINT “B IS GREATER”

STOP

FALSE TRUE

TRUETRUE

Page 21: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

MS-EXCEL

21

Page 22: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:2.a Chart - Line, XY, Bar and Pie.

Aim:

To create different types of charts (lines, xy, bar & pie)

Procedure:

Step1: Enter the data in the worksheet

Step2: choose chart option from the insert menu

Step3: choose the appropriate chart type from the chart type list box then click next.

Step4: now the chart is displayed on your active worksheet

Step 5: Heading for chart is inserted by using chart toolChart Layouts

BAR CHART

22

Page 23: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

LINE CHART

XY CHART

23

Page 24: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

PIE CHART

Result: Thus the different types of chart is created using ms-excel

24

Page 25: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:2.b Formula - formula editor

Aim:

To prepare a work sheet for storing subject marks of the students using formula and functions

and to calculate the student and subject wise total and average marks.

Procedure:

Step 1: Create a new work sheet in Ms-Excel, by clicking Start Program Ms-Excel.

Step 2: Enter the 10 number of student details into the respective cells.

Step 3: Click the cell in which you want to enter the formula for finding the total of each student.

Step 4: Now type= (equal sign) first and type sum (starting cell:end cell) which equals to sum of

the subject marks and finally press “Enter”. Now the total marks of first student are

displayed in the cell.

Step 5: Repeat the Step 4 to get the individuals total marks of each students is in the cells.OR

select the previous cell and drag it from the corner to the remaining cells.

Step 6: Now click on the cell and type the formula = Average (starting cell:end cell) and use the

procedures from the remaining cells.

Step 7: Apply = Sum (:) formula to find the total of each subject.

FORMULA EDITOR

Result: Thus the work sheet for storing subject marks of the students using formula and

functions is created and output is verified.

25

Page 26: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:2.c Spread sheet - inclusion of object, Picture and graphics, protecting the document and sheet

Aim:To create a worksheet with inclusion of object, picture and graphics and to protect the document

and sheet

Procedure:

Step 1: Create a new worksheet in Ms-Excel by clicking Start Programs Ms-Excel.

Step 2: Inserting object in the work sheet. There are many objects can be inserted into the work

sheet.

a). Choose object option in the insert menu.

b). Choose picture option form the insert menu.

c). Choose appropriate object from the AutoShape menu at the drawing toolbox.

Step 3: Inserting a picture

Select Insert Picture From File

Now the insert picture dialog box is shown

Navigate and choose the picture to insert into the work sheet click on insert button

Now the selected picture is inserted into Ms-Word.

Step 4: Protect a sheet in Ms-Excel.

Choose Home Format choose Protect Sheet. It shows the protection dialog box

asking for the password to protect sheet.

Type the password and click ok. It will ask for confirmation password, type the same

password again and then click OK

Now the sheet is under protection

To remove protection, choose Home Format Unprotect Sheet. Then type the

password to unprotect

26

Page 27: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

INCLUSION OF PICTURE

INCLUSION OF OBJECTStep 1:

27

Page 28: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

INCLUSION OF PROTECTIONStep 1:

Step 2:

28

Page 29: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step 3:

Step 4:

Results:

Thus the worksheet is created with the given features and output is verified.

29

Page 30: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:2.d Spread sheet to analyze the marks of the students

Aim:

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

appropriate charts.

Procedure:

Step 1: Click Start Program Microsoft Excel.

Step 2: Open a new spreadsheet and enter the mark details for the students.

Step 3: Now to calculate the ranges of marks among the students

Step 4: Enter the formula in formula editor to find the range of marks

Eg: =COUNTIF (B2:B15,”>80”) COUNTIF (B2:B15,”>101”)

Step 5: Select the appropriate chart from Chart wizard.

Step 6: Finally the chart is plotted for the student mark analysis in Excel sheet.

MARK ANALYSIS

Results:

Thus the spreadsheet was created by analyzing the marks of the students with appropriate charts.

30

Page 31: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:2.e Sorting and Import / Export features.

Aim:

To prepare a worksheet to sort the student details and import the data to the worksheet

Procedure:

SORTING THE DATA

Step 1: Enter the student database in the worksheet

Step 2: Select the column to be sorted

Step 3: Click Data Sort option in menu bar

Step 4: The sort dialog box appears

Step 5: Select the sorting type (Ascending/Descending) and click “Ok”

Step 6: Now the list is sorted as specified.

IMPORTING THE DATA

Step 7: To import the data, click Data Get External Data Import Text File….

Step 8: Import Dialog will appear.

Step 9: Select the file to import in excel document and click “Import” button.

Step 10: Finally the data is imported in the current document.

SORTING DATA

31

Page 32: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

IMPORTED DATA:

Step 1:

Step 2:

32

Page 33: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step 4:

Step5:

33

Page 34: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Step 6:

Step 7:

Step 8:

Results:Thus the data has been imported and sorted in the excel document.

34

Page 35: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

MS-POWER POINT

35

Page 36: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:3. Presentation for the department with power point using animation, design templates and effective presentation.

Aim:

To create a presentation in PowerPoint for department function using animations, design

template and to present effectively

Procedure:

Step 1: Click on Start Program Microsoft Power Point.

Step 2: Click on Blank Presentation option and click “Ok” button.

Step 3: New Slide dialog box will appear.

Step 4: Choose themes from the design menu and type the text in the text box.

Step 5: Insert clip art objects to the required size in desired location.

Step 6: Click Slide Show Animation. You will get different types of animation.

Step 7: Click Format Side Design Design Template is applied.

Step 8: Finally run the presentation by pressing “F5” button.

POWER POINT PRESENTATION

Slide 1:

36

Page 37: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Slide 2:

Slide 3:

Result: Thus the presentation has been created for department function using Ms-Power Point.

37

Page 38: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

C PROGRAMMING

38

Page 39: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:4 Simple Menu Driven Calculator Program Using Switch Statement

Aim:

To write a C Program to write a simple menu driven calculator program using switch statement.

Algorithm:

Step 1: Start the programStep 2: Read the two variable num1 and num2Step 3: Display menu Step 4: Enter the option code Step 5: Evaluate option code with case statements Step 5.1: case 1 ans1=num1+num2, print ans1. goto step 7 Step 5.2: case 2 ans1=num1-num2, print ans1. goto step 7 Step 5.3: case 3 ans1=num1*num2, print ans1. goto step 7 Step 5.4: case 4 ans2=(float)num1/num2, print ans2. goto step 7 Step 6: Entered case option is invalid code the print “Wrong Choice” Step 7: Stop the program

Program:

#include<stdio.h> #include<conio.h> void main() {

int num1,num2,ans1,choice;float ans2;clrscr();printf(" enter two numbers");scanf("%d%d",&num1,&num2);printf(" enter your choice \n 1.Addition \n 2.Subtraction \n

3.Multiplication \n 4.Division \n");scanf("%d",& choice);switch(choice){

case 1:ans1=num1+num2;printf("Addition =%d",ans1);break;

case 2:ans1=num1-num2;printf("Subtraction =%d",ans1);break;

case 3:ans1=num1*num2;

39

Page 40: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

printf("Multiplication =%d",ans1);break;

case 4:ans2=(float)num1/num2;printf("Division =%d",ans2);break;

default:printf("wrong choice");break;

}getch();

}

/*OUTPUT FOR ADDITION: enter two number 55 66 enter your choice 1.Addition 2.Subtraction 3.Multiplication 4.Division 1 Addition=121*/

/*OUTPUT FOR SUBTRACTION: enter two number 67 66 enter your choice 1.Addition 2.Subtraction 3.Multiplication 4.Division 2 Subtraction=1*/

/*OUTPUT FOR MULTIPLICATION: enter two number 4 2 enter your choice 1.Addition 2.Subtraction 3.Multiplication 4.Division

40

Page 41: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

3 Multiplication=8 */

/*OUTPUT FOR DIVISION: enter two number 55 5 enter your choice 1.Addition 2.Subtraction 3.Multiplication 4.Division 4 Division =11*/

/*OUTPUT FOR WRONG CHOICE: enter two number 55 66 enter your choice 1.Addition 2.Subtraction 3.Multiplication 4.Division 5 wrong choice

Result: Thus the program to create simple menu driven calculator using switch has been successfully executed.

41

Page 42: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:5 To Find Age in terms of years, months and days

Aim:

To write a C Program to find age in terms of years, months and days

Algorithm:

Step 1: Start the programStep 2: Read the birth_year, birth_month,brith_dayStep 3: Print the date of birthStep 4: Read the today_year,today_month,today_dayStep 5: Calculate years=today_year-birth_yearStep 6: If birth_month is greater than today_monthStep 6.1: years=years-1Step 6.2: If birth_day is greater than today_dayStep 6.3: Calculate, months=today_month-birth_month+12

no_days=x[birth_month]-birth_daydays=no_days+birth_day

Step 6.4: Otherwise, months=today_month-birth_month+12;days=today_day-birth_day;

Step 7: Otherwise, If birth_day is greater than today_dayStep 7.1: Calculate, months=today_month-birth_month-1

no_days=x[birth_month]-birth_daydays=birth_day+no_days

Step 7.2: Otherwise, months=today_month-birth_month;days=today_day-birth_day;

Step 8: Print the age of year,month,date

Program:

#include<stdio.h>#include<conio.h>#include<string.h>void main(){

int years,months,days,no_days;static int x[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};char month[5];int birth_year,birth_month,birth_day;int today_year,today_month,today_day;clrscr();printf("\n enter the birthyear");scanf("%d",&birth_year);printf("\n enter the birthmonth");scanf("%d",&birth_month);printf("\n enter the birthday");

42

Page 43: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

scanf("%d",&birth_day);printf("\n your date of birth %d-%d-%d",birth_day,birth_month,birth_year);printf("\n enter the todayyear");scanf("%d",&today_year);printf("\n enter the todaymonth");scanf("%d",&today_month);printf("\n enter thetodayday");scanf("%d",&today_day);printf("\n today's date is %d-%d-%d",today_day,today_month,today_year);years=today_year-birth_year;if(birth_month>today_month){

years=years-1;if(birth_day>today_day){

months=today_month-birth_month+12;no_days=x[birth_month]-birth_day;days=no_days+birth_day;

}else{

months=today_month-birth_month+12;days=today_day-birth_day;

}}else{

if(birth_day>today_day){

months=today_month-birth_month-1;no_days=x[birth_month]-birth_day;days=birth_day+no_days;

}else{

months=today_month-birth_month;days=today_day-birth_day;

}}printf("\n your age is %d years %d months %d days",years,months,days);getch();

}

/* Output

43

Page 44: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

enter the birthyear 1987 enter the birthmonth 9 enter the birthdy 29 your date if birth is 29-9-1987 enter the todayyear 2009 enter the todaymonth 11 enter the todayday 6 today's date is 6-11-2009 your age is 22years 1month 30days */

Result:

Thus the program to find the age in terms of years, months and days has been executed

successfully.

44

Page 45: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:6 Multiplication table for the given numberAim:To write a C Program to print multiplication table for the given number

Algorithm:Step 1: Start the programStep 2: Read the table number you want to print, say tableStep 3: For i=1 to 12

Print the value of i * tableStep 4: Stop the program

Program:#include<stdio.h>#include<conio.h> void main() {

int table;int i,count;printf("enter the number of tables you want to print\n");scanf("%d",&table);printf("result\n");for(i=1;i<12;i++)

{printf("%d * %d =%d\n",i,table,i*table);

} getch(); }/* OUTPUT: enter the number of tables you want to print 2 result 1* 2=2 2 * 2=4 3 * 2=6 4 * 2=8 5 *2=10 6 *2=12 7 *2=14 8 *2=16 9 *2=18 10 *2=20 11 *2=22 */

Result:Thus the program for printing multiplication table has been executed successfully.

45

Page 46: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:7.a PalindromeAim:

To create a ’C’ program for checking and printing whether the given number is a palindrome or

not.

Algorithm:Step 1: Start the programStep 2: Read the value of nStep 3: Initialize result=0 and sum=0Step 4: Assign e=nStep 5: Repeat the following steps until n>0

Step 5.1: result = n%10Step 5.2: sum = sum*10 + resultStep 5.3: n = n/10

Step 6: If e=sum, Print the given number is palindromeStep 7: Otherwise, Print the given number is not palindromeStep 5: Stop the program

Program:#include<stdio.h>#include<conio.h> void main() { int n, result=0, sum=0,e; clrscr(); printf("Enter no:"); scanf("%d",&n); e=n; while(n>0) { result =n%10; sum = sum *10+ result; n=n/10; } if(e==sum)

printf("Palindrome");elseprintf("not palindrome");

getch(); } /* OUTPUT Enter no:11 palindrome Enter no:34 not palindrome */Result: Thus the program to check prints whether the give no is palindrome or not has been

executed successfully.

46

Page 47: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:7.b Prime NumberAim:

To create a C program for checking and print of given number is prime or not.

Algorithm:Step 1: Start the programStep 2: Read the value of nStep 3: Assign i=2Step 4: Repeat the following steps until i<=n-1

Step 4.1: If n % i = 0 Then Print “Not Prime” and Exit. Step 4.2: i = i+1

Step 5: if i=n then Print “Prime Number”Step 6: Stop the program

Program: #include<stdio.h> #include<conio.h> void main() { int a,c=0,i,n; clrscr();

printf(" enter the no to be checked:");scanf("%d",&n);for(i=1;i<=n;i++){ a=n%i;

if(a==0){

c=c+1;}

}if(c==2){ printf(" given no is prime"); }else

printf(" given no is not prime");getch();

} /*OUTPUT enter a no to be checked: 6 given no is not prime */

Result:

Thus the program to find whether the given number is prime or not has been executed

successfully.

47

Page 48: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:8 Fibonacci NumberAim:

To create a C program to generate the Fibonacci series for the given number.

Algorithm:Step 1: Start the programStep 2: Read the value of nStep 3: Assign f1 = 0, f2=1 and f=0Step 4: Print f1,f2Step 5: f=f1+f2Step 6: Repeat the following steps until f<n

Step 6.1 f = f1+f2Step 6.2 f1 = f2Step 6.3 f2 = fStep 6.4 Print f

Step 7: Stop the program

Program:#include<stdio.h>#include<conio.h>void main(){

int f,f1=-1,f2=1,x,a;clrscr();printf("Enter a no:");scanf("%d",&n);for(a=0;a<=n;a++){

f=f1+f2;f1=f2;f2=f;

printf("\n%d",f3);}getch();

}/*OUTPUTEnter a no: 5

0 1 1 2 3 5 */Result:

Thus the C program to generate the Fibonacci series for the given number has been executed

successfully.

48

Page 49: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:9 Largest and Smallest number in a given array

Aim:To create a program for finding the largest and smallest of the given number using array.

Algorithm:Step 1: StartStep 2: Read the value of 10 array elements a[0],a[1]…a[9] using for loop.Step 3: Assign max=a[0],i=0;Step 4: Repeat the following steps until i=n using for loop

(i) If max < a[i+1] then assign max=a[i+1] and i=i+1Step 5: Print the value of maxStep 6: Assign min=a[0],i=0;Step 7: Repeat the following steps until i=n using for loop

(i) If max < a[i+1] then assign max=a[i+1] and i=i+1Step 8: Print the value of minStep 9: Stop

Program:

#include<stdio.h> #include<conio.h> void main() {

int a[10],i,j,x,max,min;clrscr();printf("Enter 10 nos:");for(x=0;x<10;x++){

scanf("%d",&a[x]);}max=a[0];for(i=0;i<10;i++){

if(max<a[i+1])max=a[i+1];

}printf("largest no is %d",max);min=a[0];for(j=0;j<10;j++){

if(min>a[j+1])min=a[j+1];

}printf("\nsmallest no is %d",min);getch();

49

Page 50: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

}

/*OUTPUT Enter 10 nos:12

232189543256105427largest no is 89smallest no is 10*/

RESULT:Thus the program to find the largest and smallest using arrayn has been executed successfully using array.

50

Page 51: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:10 Ascending / Descending Order

Aim:To create a program for sorting the number in an array ascending and descending order.

Algorithm:Step 1: Start the programStep 2: Read the value of n.Step 3: Read the value of n array elements a[0],a[1]…a[n-1] using for loop.Step 4: For i=0 to n

For j=i+1 to nIf a[i] > a[j] then assign temp=a[i], a[i]=a[j], a[j]=temp.

Step 5: For i=0 to n Print the value of a[i] to print the numbers in ascending order

Step 6: For i=n-1 to 0 Print the value of a[i] to print the numbers in descending order

Step 7: Stop the program

Program:

#include<stdio.h>#include<conio.h>void main(){

int a[10],n,i,j,temp;clrscr();printf("Enter the no of values");

scanf("%d",&n);printf("Enter the elements one by one\n");for(i=0;i<n;i++)scanf("%d",&a[i]);for(i=0;i<n;i++){for(j=i+1;j<n;j++){if(a[i]>a[j]){temp=a[i];a[i]=a[j];a[j]=temp;}}}printf("\n Ascending order");for(i=0;i<n;i++)printf("\t%d",a[i]);printf("\n Descending order");for(i=n-1;i>=0;i--)

51

Page 52: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

printf("\t%d",a[i]);getch();}

OUTPUTEnter the no of values 5Enter the elements one by one2312547690

Ascending order 12 23 54 76 90 Descending order 90 76 54 23 12

RESULT:Thus the program to sort the number in ascending and descending order has been executed.

52

Page 53: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:11 Reverse the Elements in an Array

Aim:To create a C program for reversing the elements given in an array.

Algorithm:Step 1: Start the programStep 2: Read the value of n.Step 3: Read the value of n array elements a[0],a[1]…a[n-1] using for loop.Step 4 For i=n-1 to 0

Print the value of a[i] to print the reverse of array elements.Step 5: Stop the program

Program:#include<stdio.h> #include<conio.h> void main() { int x[10],n,i;

clrscr();printf("enter the number of values");scanf("%d",&n);printf("enter the elements one by one\n");for(i=0;i<n;i++)scanf("%d",&x[i]);printf("reversed array:\n");for(i=n-1;i>=0;i--)printf("%d\n",x[i]);getch();

} /*OUTPUT enter the number of values 5 enter the elements one by one 3 5 1 26 reversed array: 6 2 1 5 3RESULT:Thus the program To reverse the elements given an array has been created and executed successfully.

53

Page 54: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:12.a MATRIX ADDITIONAim:To create a C program for perform the matrix addition.Algorithm:Step 1: Start the programStep 2: Read the number of rows and columns of two matrix say row1, col1, row2, col2.Step 3: If row1 = col1 and row2 = col2 goto Step 5Step 4: Print “Addition is not possible” goto Step 9Step 5: For i=0 To row1-1

For j=0 To col1-1 Read the value of a[i][j]

Step 6: For i=0 To row2-1 For j=0 To col2-1

Read the value of b[i][j]Step 7: For i=0 To row1-1

For j=0 To col1-1c[i][j]=a[i][j] + b[i][j]

Step 8: For i=0 To row1-1 For j=0 To col1-1

Print the value of c[i][j]Step 9: Stop the programProgram:#include<stdio.h>#include<conio.h>void main(){

int a[5][5],b[5][5],c[5][5];int row1,row2,col1,col2,i,j,k;clrscr();printf("Enter the row value of first matrix\n");scanf("%d",&row1);printf("Enter the column value of first matrix\n");scanf("%d",&col1);printf("Enter the row value of second matrix\n");scanf("%d",&row2);printf("Enter the column value of second matrix\n");scanf("%d",&col2);if((row1==row2)&&(col1==col2)){

printf("Matrix can be added \n");printf("Enter the values of first matrix\n");for(i=1;i<=row1;i++){

for(j=1;j<=col1;j++){

scanf("%d",&a[i][j]);

54

Page 55: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

}}printf("Enter the values of second matrix\n");for(i=1;i<=row2;i++){

for(j=1;j<=col2;j++){

scanf("%d",&b[i][j]);}

}

for(i=1;i<=row1;i++){

for(j=1;j<=col1;j++){

c[i][j]=a[i][j]+b[i][j];}

}printf("Sum of the two matrix is\n");for(i=1;i<=row1;i++){

for(j=1;j<=col1;j++){

printf("%d\t",c[i][j]);}printf("\n");

}}elseprintf("Addition cannot be perform");getch();

}/*OUTPUTEnter the row value of first matrix 2Enter the column value of first matrix 2Enter the row value of second matrix 2Enter the column value of second matrix 2Matrix can be addedEnter the values of first matrix

2 4 5 6

RESULT: Thus the program to perform matrix addition has been executed successfully.

55

Page 56: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:12.b MATRIX MULTIPLICATION

Aim:To create a program for perform the matrix multiplication.

Algorithm:Step 1: Start the programStep 2: Read the number of rows and columns of two matrix say row1, col1, row2, col2.Step 3: If row1 = col2 goto Step 5Step 4: Print “Multiplication is not possible” goto Step 9Step 5: For i=0 To row1-1

For j=0 To col1-1 Read the value of a[i][j]

Step 6: For i=0 To row2-1 For j=0 To col2-1

Read the value of b[i][j]Step 7: For i=0 To row1-1

For j=0 To col2-1Assign c[i][j]=0 For k=0 To col1-1

c[i][j]=c[i][j] + a[i][k] * b[k][j]Step 8: For i=0 To row1-1

For j=0 To col2-1 Print the value of c[i][j]

Step 9: Stop the program

Program:#include<stdio.h> #include<conio.h> Void main ()

{int a[5][5],b[5][5],c[5][5];int row1,row2,col1,col2,i,j,k;clrscr();printf("Enter the row value of first matrix\n");scanf("%d",&row1);printf("Enter the column value of first matrix\n");scanf("%d",&col1);printf("Enter the row value of second matrix\n");scanf("%d",&row2);printf("Enter the column value of second matrix\n");scanf("%d",&col2);if((row1==row2)&&(col1==col2)){printf("Matrix can be multiply \n");printf("Enter the values of first matrix\n");

56

Page 57: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

for(i=1;i<=row1;i++){for(j=1;j<=col1;j++){scanf("%d",&a[i][j]);}}printf("Enter the values of second matrix\n");for(i=1;i<=row2;i++){for(j=1;j<=col2;j++){scanf("%d",&b[i][j]);}}for(i=1;i<=row1;i++){for(j=1;j<=col1;j++){

for(k=1;k<=col1;k++){

c[i][j]=c[i][j]+a[i][k]*b[k][j];}

}}printf("Multiplication of the two matrix is\n");for(i=1;i<=row1;i++){for(j=1;j<=col1;j++){printf("%d\t",c[i][j]);}printf("\n");}}else{printf("Multiplication cannot be perform");}getch();

}

Output: Enter the row value of first matrix 2 Enter the column value of first matrix

57

Page 58: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

2 Enter the row value of second matrix 2 Enter the column value of second matrix 2 Matrix can be multiply Enter the values of first matrix 22 4 3 1Enter the values of second matrix7 89 5Multiplication of the two matrix is154 3227 5

Result:Thus the program to perform matrix multiplication has been created and verified.

58

Page 59: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:13.a STRING COPYAim:

To create a C program to copy the string using string functions

Algorithm:

Step 1: Start the programStep 2: Read the value of string strStep 3: Copy the string from str to str1 using strcpy(str1,str)Step 4: Print the copied string str1.Step 5: Stop the program.

Program:#include<stdio.h>#include<conio.h>#include<string.h>void main(){ char str[50],str1[50]; clrscr(); printf("Enter the string:"); gets(str); strcpy(str1,str); printf("Copied string is: %s",str1); getch();}

Output:Enter the string: CCETCopied string is: CCET

Result:Thus the c program to copy the string has been executed successfully.

59

Page 60: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:13.b STRING LENGTHAim:

To create a C program to find the length of the string using string functions

Algorithm:Step 1: Start the programStep 2: Read the value of string strStep 3: Compute the length of the string using strlen(str) as

len=strlen(str);Step 4: Print the length of the string len.Step 5: Stop the program

Program#include<stdio.h>#include<conio.h>#include<string.h>void main(){ char str[50]; int len; clrscr(); printf("Enter the string:"); gets(str); len=strlen(str); printf("Length of the string: %d",len); getch();}

Output:Enter the string: CCETLength of the string: 5

Result:Thus the c program to find the length of the string has been executed successfully.

60

Page 61: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:13.c STRING CONCATENATION

Aim:

To create a C program to find the concatenation of the string using string functions

Algorithm:

Step 1: Start the program Step 2: Read the value of two strings str.str1Step 3: Concatenate the string using strcat(str,str1)Step 4: Print the concatenated string str.Step 5: Stop the program.

Programs:

#include<stdio.h>#include<conio.h>#include<string.h>void main(){ char str[50],str1[50]; clrscr(); printf("Enter the first string:"); gets(str); printf("Enter the second string:"); gets(str1); strcat(str,str1); printf("Combined string is: %s",str); getch();}

Output:Enter the first string: CCETEnter the second string: EngineeringCombined string is: CCET Engineering

Result:Thus the c program to find the concatenation of the string has been executed successfully.

61

Page 62: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:13.d STRING COMPARISON

Aim:

To create a C program to compare the string using string functions

Algorithm:Step 1: Start the programStep 2: Read the value of two strings str,str1Step 3: Compare the string using strcmp(str,str1)

(i) If strcmp(str,str1) = 0 then print “Strings are equal”(ii) Otherwise print “Strings are not equal”

Step 4: Stop the program.

Programs:#include<stdio.h>#include<conio.h>#include<string.h>void main(){ char str[50],str1[50]; clrscr(); printf("Enter the first string:"); gets(str); printf("Enter the second string:"); gets(str1); if(strcmp(str,str1)==0) { printf("Strings are equal."); } else { printf("Strings are not equal."); } getch();}

Output:Enter the first string: CCETEnter the second string: engineering

Strings are not equal.

Result:Thus the c program to compare the string has been executed successfully.

62

Page 63: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:13.e STRING REVERSE

Aim:

To create a C program to find the reverse of the string using string functions

Algorithm:

Step 1: Start the programStep 2: Read the value of string strStep 3: Reverse the string using strrev(str)Step 4: Print the reversed stringStep 5: Stop the program.

Programs:

#include<stdio.h>#include<conio.h>#include<string.h>void main(){ char str[50]; clrscr(); printf("Enter the string:"); gets(str); printf("Reverse String: %s",strrev(str)); getch();}

Output:Enter the string: CCETReverse String: TECC

Result:Thus the c program to find the reverse of the string has been executed successfully.

63

Page 64: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:14 Alphabetical order

Aim: To create a ‘C’ program for arranging the names in alphabetical order

Algorithm:Step 1: Start the programStep 2: Read the value for number of names say num.Step 3: Read the value of x[i] from i=0 to num-1.Step 4: For i=0 to num

For j=i+1 to numCompare x[i] with x[j] using strcmp(). If the function returns value greater

than 0,Swap x[i] and x[j] using strcpy() function.

Step 5: For i=0 to numPrint the value of x[i] to print the names in alphabetical order.

Step 6: Stop the program

Program:#include<stdio.h>#include<conio.h>#include<string.h>void main(){char x[50][50],temp[10][10];int num,i,j;clrscr();printf("Enter the number of names:\n");scanf("%d",&num);printf("Enter the names one by one :\n");for(i=0;i<num;i++)scanf("%s",&x[i]);for(i=0;i<num;i++)for(j=i+1;j<num;j++)if(strcmp(x[i],x[j])>0){strcpy(temp,x[i]);strcpy(x[i],x[j]);strcpy(x[j],temp);}printf("The names in alphabetical order\n");for(i=0;i<num;i++)printf("\n%s",x[i]);getch();}

64

Page 65: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Output:Enter the number of names:4Enter the names one by one :sitaarunkrishnamohammed

The names in alphabetical orderarunkrishnamohammedsita

Result:Thus the program to arrange names in alphabetical order has been executed successfully.

65

Page 66: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:15 SEQUENTIAL SEARCH

Aim: To create a ’c’ program for performing the sequential search using functions

Algorithm:Step 1: Start the programStep 2: Read the value of n.Step 3: Read the value of array of elements a[i] from i=0 to n-1.Step 4: Read the element to be searched.Step 5: Assign flag=0Step 6: For i=0 to n

If the value of a[i] is equal to element to be searched then Print “Element is found” Assign flag=1

Step 7: If flag=0 then Print “Element is not present”Step 8: Stop the program

Program:#include<stdio.h>#include<conio.h>void search(int,int[],int);void main(){int i,no,element,as[100];clrscr();printf("Enter the limit:\n");scanf("%d",&no);printf("Enter the element:\n");for(i=1;i<=no;i++)scanf("%d",&as[i]);printf("Enter the element to be searched:\n");scanf("%d",&element);search(no,as,element);getch();}void search(int n,int a[],int ele){int i;for(i=0;i<n;i++){if(a[i]==ele){printf("element is found");return;

66

Page 67: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

}}printf("element is not found");return;}

Output:Enter the limit:3Enter the element:1 2 3Enter the element to be searched:2element is found

Enter the limit:3Enter the element:1 2 3Enter the element to be searched:7element is not found

Result:Thus the program to perform sequential search using function has been executed successfully.

67

Page 68: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:16 Factorial of a number using recursion

Aim:

To create a program for finding the factorial of the number using function.

Algorithm:

Step 1: Start the programStep 2: Read the value of n.Step 3: Assign f = Call fact(n)Step 4: Print the value of fStep 5: Stop the program

Function fact(int n)Step 1: If n=0 or 1 then return 1Step 2: If n!=0 or 1 then return n*fact(n-1)

Program:#include<stdio.h> #include<conio.h> int fact(int k)

{if(k==0)return 1;elsereturn k*fact(k-1);}

void main(){int n;clrscr();printf("\n Enter a number :");scanf("%d",&n);printf("\n Factorial value=%d",fact(n));getch();}

Output:

Enter a number: 4

Factorial value=24

Result:

Thus the program to find the factorial of the given number function has been executed

successfully.

68

Page 69: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:17.a Trigonometric Series-Cosine

Aim:To write the C Program to find the value for Cosine series.

Algorithm:Step 1: Start the programStep 2: Read the value of angleStep 3: Assign angle = angle * 3.14/180.Step 4: Assign radian=1, sum=1Step 5: For i=1 to 21

radian=(radian*pow( (double) (-1),(double) (2 * i - 1)) * angle * angle)/ (2 * i * (2 * i - 1));sum=sum+radian;

Step 6: Print the value of sumStep 7: Stop the program.

Program:#include<stdio.h>#include<conio.h>#include<math.h>void main(){int i;float angle,sum,val,radian;clrscr();printf("Enter angle");scanf("%f",&angle);val=angle;angle=angle*3.14159/180;radian=1,sum=1;for(i=1;i<=21;i++){radian=(radian*pow( (double) (-1),(double) (2 * i - 1)) * angle * angle)/ (2 * i * (2 * i - 1));sum=sum+radian;}printf("Cosine value of %f=%f \n",val,sum);getch();}OUTPUT:Enter angle 45Cosine value of 45.000000=0.707107

RESULT:Thus the C Program has been written to find the value for cosine series.

69

Page 70: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.NO:17.b Trigonometric Series-Sine

Aim:To write the C Program to find the value for sine series Algorithm:

Step 1: Start the programStep 2: Read the value of angleStep 3: Assign angle = angle * 3.14/180.Step 4: Assign radian=1, sum=1Step 5: For i=1 to 21

radian=(radian*pow( (double) (-1),(double) (2 * i - 1)) * angle * angle)/ (2 * i * (2 * i + 1));sum=sum+radian;

Step 6: Print the value of sumStep 7: Stop the program.

Program:

#include<stdio.h>#include<conio.h>#include<math.h>void main(){int i;float angle,sum,val,radian;clrscr();printf("Enter angle");scanf("%f",&angle);val=angle;angle=angle*3.14159/180;radian=angle;sum=angle;for(i=1;i<=21;i++){radian=(radian*pow( (double) (-1),(double) (2 * i - 1)) * angle * angle)/ (2 * i * (2 * i + 1));sum=sum+radian;}printf("Sine value of %f=%f \n",val,sum);getch();}OUTPUT:Enter angle 90Sine value of 90.000000=1.000000

Result:Thus the C Program has been written to find the value for sine series.

70

Page 71: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:18 MARKSHEET OF ‘N’ STUDENTS USING STRUCTURES

Aim: To create a program to print the mark sheet of ‘n’ student using structures

Algorithm:Step 1: Start the programStep 2: Create the structure student with fields name, rollno, m1,m2,m3,total.Step 3: Create the structure variable s1[10] for the structure student.Step 4: Read the number of students num.Step 5: Read the value of name, rollno, marks (m1,m2,m3) for the specified number of

students using structure variable s1[i] for i= 0 to num.Step 6: Calculate the total for each student using s1[i] for i=0 to num.Step 7: For i=0 to num

Print the students details such as name, rollno, marks and total for all students using s1[i]

Step 8: Stop the program

Program:#include<stdio.h>#include<conio.h>struct student{char name[10][10];int rollno,m1,m2,m3,total;};void main(){int num,i,j;struct student s1[10];clrscr();printf("enter the number of students");scanf("%d",&num);for(i=0;i<num;i++){ printf("Enter the roll number\n");scanf("%d",&s1[i].rollno);printf("Enter the name \n");scanf("%s",&s1[i].name);printf("Enter the mark1\n");scanf("%d",&s1[i].m1);printf("Enter the mark2\n");scanf("%d",&s1[i].m2);printf("Enter the mark3\n");scanf("%d",&s1[i].m3);s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;

71

Page 72: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

}printf("The details of the mark list is as follows \n");printf("\nRollno");printf("\tname ");printf("\tmark1");printf("\tmark2");printf("\tmark3");printf("\ttotal");printf("\n");for(i=0;i<num;i++){ printf("\n%d",s1[i].rollno);printf("\t%s",s1[i].name);printf("\t%d",s1[i].m1);printf("\t%d",s1[i].m2);printf("\t%d",s1[i].m3);s1[i].total=s1[i].m1+s1[i].m2+s1[i].m3;printf("\t%d",s1[i].total); }getch();}Output:enter the number of stuents2Enter the roll number4561Enter the namelokeshEnter the mark1 98Enter the mark2 78Enter the mark3 69Enter the roll number4562Enter the namemaniEnter the mark1 88Enter the mark2 89Enter the mark3 98The details of the mark list is as follows

Rollno name mark1 mark2 mark3 total4561 lokesh 98 78 69 2454562 mani 88 89 98 275

Result:The program to print the mark sheet of students using structure has been executed successfully.

72

Page 73: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:19 ARRAY USING POINTERS

Aim:To write a “C” Program to print elements of array using pointers.

Algorithm:Step 1: Start the programStep 2: Read the value of n.Step 3: Read the value of array of elements x[i] from i=0 to n-1.Step 4: Assign the address of x[0] to pointer variable pStep 5: For i=0 to n

Print the value of array elements using pointer variable pStep 6: Stop the program

Program:#include<stdio.h>#include<conio.h>void main(){int i,n,x[10];int *ipa;clrscr();printf("Enter the number of elements:\n");scanf("%d",&n);printf("Enter the number of array one by one\n");for(i=0;i<n;i++)scanf("%d",&x[i]);printf("The elements present in the array is\n");ipa=&x[0];for(i=0;i<n;i++)printf("\n%d",*(ipa+i));getch();}

Output:Enter the number of elements:4Enter the number of array one by one8201

The elements present in the array is

73

Page 74: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

8201

Result:Thus a C program has been written to print elements of array using pointers.

74

Page 75: RECORD NOTE BOOK - Web viewTo manipulate the text document with scientific notation using ms-word. Procedure: Step 1: select startprogram Microsoft word. Step 2: click Filenew and

Ex.No:20 Demonstration of UnionAim:

To create a “C” program to demonstrate the union.Algorithm:

Step 1: Start the programStep 2: Create the union Data with fields of integer variable i, float variable f and character array variable str.Step 3: Create the union variable data for the union Data.Step 4: Print the size of union using sizeof() operator.Step 5: Assign the value to variable i and f using union variable data.Step 6: Print the value of i and f using union variable data.Step 7: Copy the string say “C Programming” to str variable using union variable data.Step 8: Print the string using union variable data.Step 9: Stop the program

Program:#include <stdio.h>#include <string.h>#include<conio.h> union Data{ int i; float f; char str[20];}; int main( ){ union Data data;

clrscr();printf( "Memory size occupied by data : %d\n", sizeof(data));

data.i = 10; printf( "data.i : %d\n", data.i); data.f = 220.5; printf( "data.f : %f\n", data.f); strcpy( data.str, "C Programming"); printf( "data.str : %s\n", data.str); return 0;}Output:Memory size occupied by data : 20data.i : 10data.f : 220.500000data.str : C Programming

Result:The program to demonstrate the union has been executed successfully.

75