first bsc lab record

91
VISITING CARD Aim : Prepare a Visiting Card for a Managing Director for the Company KAL InfoTech as per the following specifications. Size of the visiting Card 3.5” x 2” Name of the Company with a big font. Phone number and e-mail address with appropriate symbols Office and residence address separated by a line. Procedure : Step 1: Start MS Word Start Programs MS Word Step 2: It opens the MS Word editor. Click on File menu and Select the page setup option. Step 3: It opens the page setup dialog box. Change the left, right, top and bottom margins to 0.1” Step 4: Select the Paper Size Tab and change the width, height to 3.5” X 2” respectively and select landscape option in orientation frame. Click OK. Step 5: Start designing your Card. 1

Upload: murali-mohan-reddy

Post on 20-Jan-2016

31 views

Category:

Documents


0 download

DESCRIPTION

lab record

TRANSCRIPT

Page 1: First Bsc Lab Record

VISITING CARD

Aim: Prepare a Visiting Card for a Managing Director for the Company KAL InfoTech

as per the following specifications. Size of the visiting Card 3.5” x 2” Name of the Company with a big font. Phone number and e-mail address with appropriate symbols Office and residence address separated by a line.

Procedure:

Step 1: Start MS Word Start Programs MS Word

Step 2: It opens the MS Word editor. Click on File menu and Select the page setup option.

Step 3: It opens the page setup dialog box. Change the left, right, top and bottom margins to 0.1”

Step 4: Select the Paper Size Tab and change the width, height to 3.5” X 2” respectively and select landscape option in orientation frame. Click OK.

Step 5: Start designing your Card.

1

Page 2: First Bsc Lab Record

2

Page 3: First Bsc Lab Record

MAIL MERGE

Aim: Create an interview call letter as the main document and create 4 records for 4

persons. Use mail merge to create a common letter to all these four.

Procedure:

Step 1: Start MS Word Start Programs MS Word

Step 2: It opens the MS Word editor. Click on Tools and select Mail Merge Option.

Step3: It opens the mail merge helper wizard. Click on Create button and select form letters option. Specify the window in which it has to create the records.

Step 4: Click on Active Window.

Step 5: Click on Get Data button and select Create data Source option. It opens create data source window in which we select the fields required for our mail. Click on OK Button and provide the file name.

Step 6: Click on Edit Data Source It opens the Data Form window and we need to provide the details. Finally click on OK

Step 7: Write your letter.

Step 8: Click on Insert Merge field in the menu bar, to insert the fields in the To Address of your letter.

Step 9: Click on <<ABC>> Button to Merge the values.

Step 10:Click on Merge Button. It opens the Merge options. Select Merge and Click OK.

3

Page 4: First Bsc Lab Record

Tirupati,28-09-2010.

FromS. Amar DeepM.D.Swiss Solutions Tirupati.

To«Firs tName»«Address2»«City»«PostalCode»

Sub: Interview Call Letter.

Dear Candidate,

This is to inform you that your name has been short listed for the post of

Programmer. Please attend the interview on 27-10-2010. Two copies of Biodata and all

the testimonials, along with a photo have to be carried.

Wishing for your best luck.

Yours truly,

Amar Deep

4

Page 5: First Bsc Lab Record

Tirupati,28-09-2010.

FromS. Amar DeepM.D.Swiss Solutions Tirupati.

ToKiran kumar11-12-13Tirupati517502

Sub: Interview Call Letter.

Dear Candidate,

This is to inform you that your name has been short listed for the post of

Programmer. Please attend the interview on 27-10-2010. Two copies of Biodata and all

the testimonials, along with a photo have to be carried.

Wishing for your best luck.

Yours truly,

Ajay kumar

5

Page 6: First Bsc Lab Record

Tirupati,28-09-2010.

FromS. Amar DeepM.D.Swiss Solutions Tirupati.

ToGopal Bhushan Shinday123-45/678Chennai321654

Sub: Interview Call Letter.

Dear Candidate,

This is to inform you that your name has been short listed for the post of

Programmer. Please attend the interview on 27-10-2010. Two copies of Biodata and all

the testimonials, along with a photo have to be carried.

Wishing for your best luck.

Yours truly,

Amar Deep

1

Page 7: First Bsc Lab Record

Tirupati,28-09-2010.

FromS. Amar DeepM.D.Swiss Solutions Tirupati.

ToGopi JhunJhunwala12-23/A/B/CPatiyala789456

Sub: Interview Call Letter.

Dear Candidate,

This is to inform you that your name has been short listed for the post of

Programmer. Please attend the interview on 27-10-2010. Two copies of Biodata and all

the testimonials, along with a photo have to be carried.

Wishing for your best luck.

Yours truly,

Amar Deep

1

Page 8: First Bsc Lab Record

Tirupati,28-09-2010.

FromS. Amar DeepM.D.Swiss Solutions Tirupati.

ToGopi Mihir#452Tirupati789214

Sub: Interview Call Letter.

Dear Candidate,

This is to inform you that your name has been short listed for the post of Programmer.

Please attend the interview on 27-10-2010. Two copies of Biodata and all the testimonials, along with a

photo have to be carried.

Wishing for your best luck.

Yours truly,

Amar Deep

2

Page 9: First Bsc Lab Record

MACRO

Aim : Write a MACRO to format a document as given below.1. Line spacing 22. Paragraph indent of 0.103. Justification formatting Style4. Arial font of 15Pt Size.

Procedure:

Step 1: Start MS Word Start Programs MS Word

Step 2: It opens the MS Word editor. Click on Tools and select Macros submenu and select the Record New Macro option.

Step 3: It opens the record macro dialog box.

Step 4: Click on Key Board option. It opens the Customize keyboard window. Provide the Short cut key and click on Assign button. And Click on Close Button.

Step 5: Now the recording is got started.

Step 6: Select the format Menu and Click on Paragraph option and change the Line spacing to double.

Step 7: Select the indentation to 0.10

Step 8: Select Justify in Alignment and click on Ok.

Step 9: Chang the font to Arial and its size of 15Pt Size.

Step 10: Stop the Macro Recording.

Step 11: Press the Short cut Key to apply the macro that we have recorded.

3

Page 10: First Bsc Lab Record

TYPES OF SOFTWARESoftware is a set of electronic instructions that tells the computer how to do certain tasks. A set

of instructions is often called a program. When a computer is using a particular program, it is said to be running or executing the program.

The two most common types of programs are system software and application software.

System Software

System software exists primarily for the computer itself, to help the computer perform specific functions.

One major type of system software is the operating system (OS). All computers require an operating system. The OS tells the computer how to interact with the user and its own devices. Common operating systems include Windows, the Macintosh OS, OS/2, and UNIX .

When we turn on a computer, it goes several steps to prepare itself for use. The first step is called the power-on self test (POST). The computer identifies the devices attached to it, identifies the amount of memory available, and does a quick check to see whether the memory is functioning properly.

Application Software

Application software tells the computer how to accomplish tasks the user requires, such as creating a document or editing a graphic image.

Some important kinds of application software are:

Application software tells the computer how to accomplish tasks the user requires, such as creating a document or editing a graphic image.

Some important kinds of application software are: MS-OFFICE, TALLY, etc

4

Page 11: First Bsc Lab Record

TYPES OF SOFTWARESoftware is a set of electronic instructions that tells the computer

how to do certain tasks. A set of instructions is often called a program. When a computer is using a particular program, it is said to be running or executing the program.

The two most common types of programs are system software and application software.System Software

System software exists primarily for the computer itself, to help the computer perform specific functions.

One major type of system software is the operating system (OS). All computers require an operating system. The OS tells the computer how to interact with the user and its own devices. Common operating systems include Windows, the Macintosh OS, OS/2, and UNIX .

When we turn on a computer, it goes several steps to prepare itself for use. The first step is called the power-on self test (POST). The computer identifies the devices attached to it, identifies the amount of memory available, and does a quick check to see whether the memory is functioning properly. Application Software

Application software tells the computer how to accomplish tasks the user requires, such as creating a document or editing a graphic image.

Some important kinds of application software are: Application software tells the computer how to accomplish tasks

the user requires, such as creating a document or editing a graphic image.

Some important kinds of application software are: MS-OFFICE, TALLY, etc

5

Page 12: First Bsc Lab Record

CONVERSIONS

Aim: To create an electronic spread sheet in which you enter the following Decimal numbers and convert them into Octal, Hexa decimal and Binary numbers vice versa.

Procedure:

Step 1: Start MS ExcelStart Programs MS Excel

Step 2: Select Add-ins from tools menu and select the analysis toolpack check box.

Step 3: Give the necessary headings like Decimal, Binary, Octal, Hexa Decimal in the first row.

Step 4: Give the Decimal number in the Decimal heading column.

Step 5: Go to Binary column and give the formula as =dec2bin (cell address).

Step 6: Go to Octal column and give the formula as =dec2oct (cell address).

Step 7: Go to Hexa decimal column and give the formula as = dec2hex (cell address).

Step 8: Give the necessary heading in the row like Binary, Decimal, Octal and Hexa.

Step 9: Give the Binary numbers in Binary heading column.

Step 10: Go to Decimal column and given the formula as =bin2dec (cell address).

Step 11: Go to Octal column and give the formula as =bin2oct (cell address).

Step 12: Go to Hexa decimal and given the formula as =bin2hex (cell address).

6

Page 13: First Bsc Lab Record

CONVERTING FROM DEC TO BIN,OCT AND HEXADECIMAL

       DECIMAL BINARY OCTAL HEXADECIMAL35 100011 43 2368 1000100 104 4495 1011111 137 5F165 10100101 245 A5225 11100001 341 E1355 101100011 543 163375 101110111 567 177465 111010001 721 1D1                     

CONVERTING FROM BIN TO DEC,OCT AND HEXADECIMAL

       BINARY DECIMAL OCTAL HEXADECIMAL

101 5 5 51101 13 15 D111011 59 73 3B10001 17 21 11110011001 409 631 199111011111 479 737 1DF

7

Page 14: First Bsc Lab Record

STUDENT RESULT

Aim: Create a Suitable examination database and find the sum of the marks of each student and the

respective class secured by the student.

Pass – 35% Distinction – 75% First class – 60% Second Class – 50% Third Class – 35%

Procedure:

Step 1: Start MS ExcelStart Programs MS Excel

Step 2: Provide the Necessary data.

Step 3: In the Total Field for the First Record Write the following formula.=D4+E4+F4

Step 4: Drag it up to the end of this column.

Step 5: In the Average Field for the First Record Write the following formula.=G4/3

Step 6: Drag it up to the end of this column.

Step 7: In the Result Field for the First Record Write the following formula.=IF(AND(D4>=35,E4>=35,F4>=35),"Pass","Fail")

Step 8: Drag it up to the end of this column.

Step 9: In the Class Field for the First Record Write the following formula.=IF(AND(I4="Pass",H4>=75),"Distinction",IF(AND(I4="Pass",H4<75,H4>=60),"First Class",IF(AND(I4="Pass",H4<60,H4>=50),"Second Class",IF(AND(I4="Pass",H4<50,H4>=35),"Third Class","Fail"))))

Step 10: Drag it up to the end of this column.

8

Page 15: First Bsc Lab Record

STUDENT DETAILS

Sno Sname Sub1 Sub2 Sub3 Total Average Result Class

1001 Arun. K 100 100 100 300 100.00 Pass Distinction

1002 Murali. R 89 98 98 285 95.00 Pass Distinction

1003 Vani. M 45 54 45 144 48.00 Pass Third Class

1004 Latha. T 78 68 56 202 67.33 Pass First Class

1005 Rajesh. L 35 34 35 104 34.67 Fail Fail

1006 Suresh. B 47 48 49 144 48.00 Pass Third Class

1007 Samad. A 12 13 14 39 13.00 Fail Fail

1008 Kiran. D 80 79 78 237 79.00 Pass Distinction

1009 Gopi. N 15 25 35 75 25.00 Fail Fail

1010 Rammurty. S 35 38 37 110 36.67 Pass Third Class

9

Page 16: First Bsc Lab Record

PRODUCT CHART

Aim:The KAL InfoTech company shows the sales of Different products for 5 years. Create Bargraph,

3D and Pie Charts for the following.

Year Product1 Product2 Product3 Product41989 1000 800 900 10001990 8000 80 500 9001991 1200 190 400 8001992 400 200 300 10001993 1800 400 400 1200

Procedure:

Step 1: Start MS ExcelStart Programs MS Excel

Step 2: Provide the Necessary data.

Step 3: Select the data and click on Charts wizard.

Step 4: It opens the charts wizard and you select the Column Option and click the next button.

Step 5: In the next window click on the next button.

Step 6: In the next window Provide the Chart title as KAL InfoTech Sales Chart

Step 7: In the X Axis provide the title as Year

Step 8: In the Y Axis provide the title as Sales and click on next button and to conclude the finish Finish.

Step 9: Resize the chart according to the need.

Step 10: The same procedure to be repeated for the 3D and Pie Graphs.

10

Page 17: First Bsc Lab Record

Bar Chart

3D Chart

PIE Chart

11

Page 18: First Bsc Lab Record

DEPARTMENT PRESENTATION

Aim: Prepare a Presentation about your Department using MS- PowerPoint.

Procedure:

Step 1: Start MS PowerPoint. Start → Programs → MS PowerPoint.

Step 2: In Slide 1 Give the Title of the Slide as Department of Computer Science.

Step 3: In Slide 2 Give the title as Origin and provide the origin information.

Step 4: In Slides 3 & 4 Give the title as Growth and provide the information about the departments Growth.

Step 5: In Slide 5 Give the title as Courses and provide necessary information.

Step 6: In Slide 6 & 7 give the Titles as B.Sc, B.Com and B.A and provide its information.

Step 7: In the slide 8 Give the title as Resources and provide the necessary information.

Step 8: In the Slide 9, 10 & 11 provide the titles Teaching, Learning and Evaluations and provide the Necessary information.

Step 9: In Slide 12 & 13 give the title as Infrastructure & Learning Resources and provide the necessary Necessary.

Step 10: Save the presentation.

12

Page 19: First Bsc Lab Record

13

Page 20: First Bsc Lab Record

14

Page 21: First Bsc Lab Record

15

Page 22: First Bsc Lab Record

16

Page 23: First Bsc Lab Record

ANDHRA BANK PRESENTATION

Aim: Prepare a Presentation about Andhra Bank using MS- PowerPoint.

Procedure:

Step 1: Start MS PowerPoint.Start → Programs → MS PowerPoint.

Step 2: In Slide 1 Give the Title of the Slide as Andhra Bank.

Step 3: In Slide 2 Give the title as Establishment and provide the establishment information.

Step 4:In Slides 3 Give the title as Types of Transactions and provide the information about the transactions.

Step 5: In Slide 4 Give the title as Savings and provide necessary information.

Step 6: In Slide 5 give the Title as Insurance Opportunities and provide its information.

Step 7: In the slide 6 Give the title as Mediclime and provide the necessary information.

Step 8: In the Slide 7 provide the title Rules and Regulations and provide the necessary information.

Step 9: In Slide 8 give the title as Policies and Shares and provide the necessary information.

Step 10: In Slide 9 give the title as ATM and provide the necessary information.

Step 11: In Slide 10 give the title as New Plans and provide the necessary information.

Step 12: In Slide 11 give the title as Conclusion and conclude the presentation by providing necessary information and save the presentation.

17

Page 24: First Bsc Lab Record

18

Page 25: First Bsc Lab Record

19

Page 26: First Bsc Lab Record

20

Page 27: First Bsc Lab Record

STUDENT DETAILS USING QUERIES

Aim: Create a database called Student using MS ACCESS with at least 10 records.

Student MarksField Name Data Type Field Name Data Typeregno Number regno Numbername Text M1 NumberDob Date M2 NumberGender Text M3 NumberClass Text M4 Number

M5 Number

Procedure:

Step 1: Start MS ACCESS. Start → Programs → MS ACCESS.

Step 2: Click on the Blank ACCESS Data base and select OK

Step 3: Provide the Database name as Student and click on Create

Step 4: It opens the Student Database window.

Step 5: In Objects frame select the Create Table in Design view option.

Step 6: It opens the table window. Here provide the field names of the student table along with data types.

Step 7: Right click on regno Field and Select the Primary key option.

Step 8: Save the table and give the name as Student.

Step 9: Repeat the steps 5, 6 and Step 8 to create the Marks table with the given fields Except Step 7.

Step 10: Click on Queries option in the objects frame and select create query in design view option.

Step 11: It opens the show table window.

Step 12: Select the table Student and click on Add button, Select the Marks table and click on Add Button. Finally click on Close button.

Step 13: Drag and drop all the required fields from the available tables to the frame given below.

Step 14: In the total field write the following formula Total : [M1]+ [M2]+ [M3]+ [M4]+ [M5]

Step 15: Save and give the name as Student query. Close the window.

Step 16: Double Click on the Student query.

Step 17: Save and close.

21

Page 28: First Bsc Lab Record

Table data

Query1 displaying regno, name, gender, total marks

22

Page 29: First Bsc Lab Record

STUDENT DETAILS USING REPORTS

Aim: Create a report called Student using MS ACCESS with at least 10 records.

Student MarksField Name Data Type Field Name Data Typeregno Number regno Numbername Text M1 NumberDob Date M2 NumberGender Text M3 NumberClass Text M4 Number

M5 Number

Procedure :

Step 1: Start MS ACCESS. Start → Programs → MS ACCESS.

Step 2: Click on the Open existing ACCESS Database and select Student and click OK.

Step 3: It opens the student database.

Step 4: Select Reports option in the objects frame and click on Create report by using Wizard option.

Step 5: Select the required fields from the different tables and queries available in the Table/queries option.

Step 6: It asks for the creation of the relation again. [If necessary] Provide the relation again and click and close the window.

Step 7: It continues with reports wizard.

Step 8: Select by marks option in how do you want to view your data frame and click on Next button.

Step 9: Click on next button again.

Step 10: Select Sno to as the sorting order and click on Next button.

Step 11: Select the layout and orientation as tabular and portrait and click on next button.

Step 12: Select the report style as Bold. And click on next button.

Step 13: Finally type the title of the report and click on Finish button.

Step 14: Save and give the name of the report and close the window.

Step 15: Double click on the report to execute the report.

23

Page 30: First Bsc Lab Record

Report 1 with Reg no, name, marks of all subjects and total

24

Page 31: First Bsc Lab Record

PRIME NUMBER or NOT

Aim :To find that whether the given number is Prime number or Not.

Algorithm :

Step 1: StartStep 2: k0Step 3: Read numStep 4: For i1 repeat until (i<=num) Step 4.1: If (num%i)=0 kk+1 Step 4.2: ii+1Step 5: If (k=2) then Write “ number is Prime ” Otherwise, Write “ number is Not Prime”Step 6: Stop.

25

Page 32: First Bsc Lab Record

Flow Chart :

False True True

False True False True

False

Start

Readmy name is

t.pts.v.arts college

suresh

num

k 0

(num%i=0)

k k+1

If (k = 2)

Write“Prime Num”

Write“Not

Prime”

StopStart

For i 1 to num

i i+1

26

Page 33: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>main(){ int num,k=0,i; clrscr(); printf("\n Enter any number : "); scanf("%d",&num); for(i=1;i<=num;i++) {

if((num%i)==0) k++;

} if(k= =2) printf("\n Number %d is PRIME",num); else printf("\n Number %d is NOT PRIME",num); getch();}

Output :

Enter any number : 7

Number 7 is PRIME

Enter any number : 4

Number 4 is NOT PRIME

27

Page 34: First Bsc Lab Record

REVERSE OF A NUMBER

Aim :To find the Reverse of a given number.

Algorithm :

Step 1: StartStep 2: rev0Step 3: Read nStep 4: numnStep 4: repeat until (num>0) Step 4.1: dignum%10 Step 4.2: revrev*10+dig Step 4.3: numnum/10Step 5: Write “reverse of the number is”, revStep 6: Stop.

28

Page 35: First Bsc Lab Record

Flow Chart :

False True

Start

Readn

rev 0

is num>0?

Write“reverse”,

rev

StopStart

num n

dig num%10rev rev*10+dignum num/10

29

Page 36: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>main(){ int n,num,dig,rev=0; clrscr(); printf("\n Enter any number : "); scanf("%d",&n); num=n; while(num>0) {

dig=num%10; rev=rev*10+dig; num=num/10;

} printf("\n Reverse of the given %d is :: %d",n,rev); getch();

}

Output :

Enter any number : 123

Reverse of the given 123 is :: 321

30

Page 37: First Bsc Lab Record

ARMSTRONG NUMBER or NOT

Aim :To find that whether the given number is Armstrong or Not.

Algorithm :

Step 1: StartStep 2: sum0Step 3: Read numStep 4: dupnumStep 4: repeat until (num>0) Step 4.1: dignum%10 Step 4.2: sumsum+(dig*dig*dig) Step 4.3: numnum/10Step 5: If (dup=sum) then Write “ number is Armstrong ” Otherwise, Write “ number is Not Armstrong”Step 6: Stop.

31

Page 38: First Bsc Lab Record

Flow Chart :

False True

False True

Source Code :

Start

Readnum

sum 0

(num>0)

dup = sum

Write“Armstron

g”

Write “Not

Armstrong”

StopStart

dup num

dig num%10sum sum+dig*dig*dignum num/10

32

Page 39: First Bsc Lab Record

#include<stdio.h>#include<conio.h>main(){ int num,dig,dup,sum=0; clrscr(); printf("\n Enter any number : "); scanf("%d",&num); dup=num; while(num>0) {

dig=num%10; sum=sum+dig*dig*dig; num=num/10;

} if(dup= =sum)

printf("\n %d is an ARMSTRONG",dup); else

printf("\n %d is NOT ARMSTRONG",dup); getch();}

Output :

Enter any number : 320

320 is NOT ARMSTRONG

Enter any number : 153

153 is an ARMSTRONG

FACTORIAL OF A NUMBER USING RECURSION

33

Page 40: First Bsc Lab Record

Aim :To find the Factorial of a given number using Recursion.

Algorithm :

Step 1: StartStep 2: read numStep 3: write “Factorial is “, call (factorial (num))Step 4: Stop

Algorithm for factorial Function :

Step 1: StartStep 2: if (n=1) then, return 1 otherwise, Step 2.1: factn*call(factorial(n-1)) Step 2.2: return fact

Flow Chart :

34

Page 41: First Bsc Lab Record

factorial

Flow chart for factorial Function :

False True

Start

Readnum

WriteFactorial(num

)

Stop

Factorial(num)

Start

If (n=1)

Return (1)

Return (fact)

Fact n*factorial(n-1)

35

Page 42: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>main(){ int num; clrscr(); printf("\n Enter any number : "); scanf("%d",&num); printf("\n Factorial of %d is :: %d",num,factorial(num)); getch();}factorial(int n){ int fact; if(n==1) return(1); else fact=n*factorial(n-1); return(fact);}

Output :

Enter any number : 6

Factorial of 6 is :: 720

36

Page 43: First Bsc Lab Record

FUNCTION PROTOTYPE

Aim :To find the Square of a given number using Function Prototype.

Algorithm :

Step 1: StartStep 2: read aStep 3: bcall(square(a))Step 4: write bStep 5: Stop.

Algorithm for square Function :

Step 1: StartStep 2: y(x*x)Step 3: return y

37

Page 44: First Bsc Lab Record

Flow Chart :

Flow chart for square Function :

Start

y x*x

Return (y)

Start

Reada

Writeb

Stop

b square(a)

38

Page 45: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>main(){ float a,b; float square(float); clrscr(); printf("\n Enter any number :"); scanf("%f",&a); b=square(a); printf("\n square of %.2f is %.2f",a,b); getch();}

float square(float x){ float y; y=x*x; return(y);}

Output :

Enter any number : 5

Square of 5.00 is 25.00

FUNCTION – CALL BY REFERENCE

39

Page 46: First Bsc Lab Record

Aim : Program to explain about the function using Call by Reference.

Algorithm :

Step 1: StartStep 2: a20, b15Step 3: write a, bStep 4: call fun(a,b)Step 5: write a,bStep 6: Stop

Algorithm for fun Function :

Step 1: StartStep 2: x30, y10Step 3: return

Flow Chart :

40

Page 47: First Bsc Lab Record

Flow chart for square Function :

Source Code :

#include<stdio.h>

Start

x 30, y 10

Return

Start

Writea, b

Writea, b

Stop

Fun (&a, &b)

a 20, b 15

41

Page 48: First Bsc Lab Record

#include<conio.h>void main(){ Void fun(int *,int *); int a=20,b=15; printf("\n Before calling function \n"); printf("a = %d \t b = %d",a,b); fun(&a,&b); printf("\n After calling function \n"); printf("a = %d \t b= %d",a,b); getch();}void fun(int *x,int *y){ *x=30; *y=10;}

Output :

Before calling function

a = 20 b = 15

After calling function

a = 30 b= 10

SORTING USING ARRAYS

42

Page 49: First Bsc Lab Record

Aim : Program for Sorting an array elements.

Algorithm :

Step 1: StartStep 2: read nStep 3: for i0 repeat until (i<n) Step 3.1: Read a[i] Step 3.2: ii+1Step 4: for i0 repeat until (i<n) Step 4.1: for j(i+1) repeat until (j<n) Step 4.1.1: if (a[i]>a[j] ) then Step 4.1.1.1: tempa[i] Step 4.1.1.2: a[i]a[j] Step 4.1.1.3: a[j]temp Step 4.1.2: jj+1 Step 4.2: ii+1Step 5: for i0 repeat until (i<n) Step 5.1: Write a[i] Step 5.2: ii+1Step 6: Stop

Flow Chart :

43

Page 50: First Bsc Lab Record

True

False

False True

True False True

FalseFalse

True

Source Code :

i i+1

Start

Read a[i]

For i 0 to (i<n)

For j (i+1) to (j<n)

If a[i]>a[j]

temp a[i]a[i] a[j]a[j] temp

j j+1

Read n

For i 0 to (i<n)

i i+1

For i 0 to (i<n)

write a[i]

i i+1

Stop

44

Page 51: First Bsc Lab Record

#include<stdio.h>#include<conio.h>main(){ int a[20],n,i,j,temp; clrscr(); printf("\n Enter array size : "); scanf("%d",&n); printf("\n Enter array elements : "); 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\n Sorted array elements are : \t\n"); for(i=0;i<n;i++)

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

Output :

Enter array size : 5

Enter array elements : 126539

Sorted array elements are :

3 5 6 9 12

MATRIX MULTIPLICATION

45

Page 52: First Bsc Lab Record

Aim : Write a program to perform Matrix Multiplication.

Algorithm :

Step 1: StartStep 2: read m,nStep 3: if (n!=m) then Step 3.1: write “multiplication is not possible” Step 3.2: goto Step 8Step 4: for i0 repeat until (i<m) Step 4.1: for j0 repeat until (j<n) Step 4.1.1: read a[i][j] Step 4.1.2: jj+1 Step 4.2: ii+1Step 5: for i0 repeat until (i<m) Step 5.1: for j0 repeat until (j<n) Step 5.1.1: read b[i][j] Step 5.1.2: jj+1 Step 5.2: ii+1Step 6: for i0 repeat until (i<m) Step 6.1: for j0 repeat until (j<n) Step 6.1.1: c[i][j]0 Step 6.1.2: for k0 repeat until (k<n) Step 6.1.2.1: c[i][j]c[i][j]+(a[i][k]*b[k][j]) Step 6.1.2.2: kk+1 Step 6.1.3: jj+1 Step 6.2: ii+1Step 7: for i0 repeat until (i<m) Step 7.1: for j0 repeat until (j<n) Step 7.1.1: write c[i][j] Step 7.1.2: jj+1 Step 7.2: ii+1Step 8: Stop.

Flow Chart :Start

46

Page 53: First Bsc Lab Record

False True True

TrueFalse

FalseTrue

True

False

True

False

True

False False True

Read a[i][j]

Read m,n

For i 0 to (i<m)

j j+1

If (n!=m)Write

“Not possible”

For j 0 to (j<n)

Read b[i][j]

For i 0 to (i<m)

j j+1

For j 0 to (j<n)i i+1

i i+1

For i 0 to (i<m)

For j 0 to (j<n)

c[i][j] 0

For k 0 to (k<n)

c[i][j] c[i][j]+(a[i][k]*b[k][j])k k+1

i i+1

j j+1

A

47

Page 54: First Bsc Lab Record

False

TrueTrue

False

Source Code :

#include<stdio.h>#include<conio.h>main(){ int a[20][20],b[20][20],c[20][20],m,n,i,j,k; clrscr(); printf("enter the order of first matrix\n"); scanf("%d%d",&m,&n); if(n!=m) { printf("\n Multiplication is not possible"); goto end; } printf("enter first matrix\n"); for(i=0;i<m;i++) for(j=0;j<n;j++) { printf("\n Enter a[%d][%d] elements\n",i,j);

Writec[i][j]

For i 0 to (i<m)

j j+1

For j 0 to (j<n)

i i+1

Stop

A

48

Page 55: First Bsc Lab Record

scanf("%d",&a[i][j]); } printf("enter second matrix\n"); for(i=0;i<m;i++) for(j=0;j<n;j++) { printf("\nEnter a[%d][%d] elements\n",i,j); scanf("%d",&b[i][j]); } for(i=0;i<m;i++) { for(j=0;j<n;j++) { c[i][j]=0; for(k=0;k<n;k++) c[i][j]=c[i][j]+(a[i][k]*b[k][j]); } } printf(“\n Multiplication Matrix is :: \n”); for(i=0;i<m;i++) { for(j=0;j<n;j++) { printf("%d\t",c[i][j]); } printf("\n"); }end: getch();}

Output :

Enter the order of first matrix22

Enter first matrix

Enter a[1][1] elements2

Enter a[1][2] elements2

Enter a[2][1] elements2

Enter a[2][2] elements2

Enter second matrix

Enter a[1][1] elements2

Enter a[1][2] elements2

Enter a[2][1] elements2

Enter a[2][2] elements2

49

Page 56: First Bsc Lab Record

Multiplication Matrix is ::

8 88 8

STRING LENGTH

Aim : To find the Length of the String using and Without using the String function.

Algorithm :

Step 1: StartStep 2: cnt0Step 3: read strStep 4: lenstrlen(str)Step 5: write lenStep 6: for i0 repeat until str[i]!=’\0’ Step 6.1: cntcnt+1 Step 6.2: ii+1Step 7: write cntStep 8: Stop

50

Page 57: First Bsc Lab Record

Flow Chart :

True True

False

Start

Read str

For i 0 to (str[i]!=’\0’)

i i+1

cnt 0

len strlen(str)

write len

cnt cnt+1

Writecnt

Stop

51

Page 58: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>#include<string.h>main(){ char str[30]; int len,i,cnt=0; clrscr(); printf("Enter the string :: \n"); gets(str); len=strlen(str); printf("\nUSING FUNCTIONS\n"); printf("The length of the string is : %d\n\n",len); printf("WITH OUT USING FUNCTIONS\n"); for(i=0;str[i]!='\0';i++) cnt++; printf("Number of characters is : %d",cnt); getch();}

Output :

Enter the string ::Arts College

USING FUNCTIONSThe length of the string is : 21

WITH OUT USING FUNCTIONSNumber of characters is : 12

52

Page 59: First Bsc Lab Record

COMPARISION OF STRINGS

Aim :To write a program to Compare two strings without using string function.

Algorithm :

Step 1: StartStep 2: read str1,str2Step 3: for i0 repeat until (str2[i]!=’\0’) Step 3.1: if (str1[i]=str2[i]) then, ii+1 otherwise, Step 3.1: write “strings are Not Equal” Step 3.2: goto step 5 Step 4: write “strings are Equal”Step 5: Stop.

53

Page 60: First Bsc Lab Record

Flow Chart :

False True

False

True

Start

Read Str1, str2

For i 0 to (str2[i]!=’\0’)

If str1[i]=str2[i]

i i+1

write“not equal”

write“equal

Stop

54

Page 61: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>#include<string.h>void main(){ char str1[30],str2[30]; int i; printf("\n Enter first string : "); gets(str1); printf("\n Enter second string : "); gets(str2); for(i=0;str2[i]!='\0'; ) {

if(str1[i]==str2[i]) i++; else { printf("\n Strings are Not equal"); exit(); }

} printf("\n Strings are Equal");}

Output :

Enter first string : computer

Enter second string : comptter

Strings are Not equal

Enter first string : this is

Enter second string : this is

Strings are Equal

55

Page 62: First Bsc Lab Record

EMPLOYEE - STRUCTURE

Aim :To write a program to create employee details using structure.

Algorithm :

Step 1: StartStep 2: read nStep 3: for i0 repeat until (i<n) Step 3.1: read emp[i].eno, emp[i].name, emp[i].age Step 3.2: ii+1Step 4: for i0 repeat until (i<n) Step 4.1: write emp[i].eno, emp[i].name, emp[i].age Step 4.2: ii+1Step 5: Stop.

56

Page 63: First Bsc Lab Record

Flow Chart :

False True

False

True

Start

Read n

For i 0 to (i<n)

i i+1

Read emp[i].eno, emp[i].nameemp[i].age

For i 0 to (i<n)

i i+1

Writeemp[i].eno, emp[i].nameemp[i].age

Stop

57

Page 64: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>struct employee{ int eno; char name[20]; int age;};

main(){ struct employee emp[10]; int n,i; clrscr(); printf("\n Enter the number of employee: "); scanf("%d",&n); for(i=0;i<n;i++) { printf("\n enter empno,empname,age for employee %d\n",i); scanf("%d%s%d",&emp[i].eno,emp[i].name,&emp[i].age); } printf("\n the company's employee profile is as follows:\n"); for(i=0;i<n;i++) { printf("\n employee %d's data\n %d\t%s\t%d\n",i,emp[i].eno,emp[i].name,emp[i].age); }getch();}

58

Page 65: First Bsc Lab Record

Output :

Enter the number of employee: 2enter empno,empname,age for employee 1101raju34

enter empno,empname,age for employee 2102ramu35

The company's employee profile is as follows:

employee 1's data 101 raju 34

employee 2's data 102 ramu 35

59

Page 66: First Bsc Lab Record

ARRAY ELEMENTS USING POINTERS

Aim :To write a program to access the array elements through pointer.

Algorithm :

Step 1: StartStep 2: paStep 3: read nStep 4: for i0 repeat until (i<n) Step 4.1: read (p+i) Step 4.2: ii+1Step 5: for i0 repeat until (i<n) Step 5.1: write *(p+i) Step 5.2: ii+1Step 6: Stop

60

Page 67: First Bsc Lab Record

Flow Chart :

False True

True

False

Start

Read n

p a

Read p+i

For i 0 to (i<n)

i i+1For i 0 to (i<n)

Write*(p+i)

i i+1

Stop

61

Page 68: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>void main(){ int a[20],i,*p,n; p=a; printf("\n Enter array size : "); scanf("%d",&n); printf("Enter array elements : \n"); for(i=0;i<n;i++)

scanf("%d",p+i); printf("\n\n Array elements are : \n"); for(i=0;i<n;i++)

printf("%d\t",*(p+i));}

Output :

Enter array size : 5Enter array elements :6532102089

Array elements are :65 32 10 20 89

62

Page 69: First Bsc Lab Record

STRUCTURE ELEMENTS USING POINTERS

Aim :To write a program to access the structure elements through pointer.

Algorithm :

Step 1: StartStep 2: read stuname,sturollno,stum1,stum2,stum3Step 3: stutotstum1+stum2+stum3Step 4: stuavgstutot/3Step 5: write stuname,sturollno,stutot,stuavgStep 6: Stop

63

Page 70: First Bsc Lab Record

Flow Chart :

Start

Read stuname,sturolln

ostum1,stum2

stum3

stutot stum1+stum2+stum3

stuavgstutot/3

writestuname,sturolln

ostutot,stuavg

Stop

64

Page 71: First Bsc Lab Record

Source Code :

#include<stdio.h>#include<conio.h>struct student{ char name[30]; int rollno,m1,m2,m3,tot; float avg;};void main(){ struct student *stu; printf("\n Enter student record as name,rollno & 3 sub marks : "); gets(stu->name); scanf("%d%d%d%d",&stu->rollno,&stu->m1,&stu->m2,&stu->m3); stu->tot=stu->m1+stu->m2+stu->m3; stu->avg=stu->tot/3; printf("\n\n The student record is :: \n"); printf("\n Name = "); puts(stu->name); printf("Rollno = %d\ntotal = %d\nAverage = %f",stu->rollno,stu->tot,stu->avg); getch();}

Output :

Enter student record as name,rollno & 3 sub marks : anusha11242523

The student record is ::

Name = anushaRollno = 11total = 72Average = 4.000000

65

Page 72: First Bsc Lab Record

FILES

Aim :

66

Page 73: First Bsc Lab Record

67

Page 74: First Bsc Lab Record

#include<stdio.h>#include<conio.h>main(){ FILE *f1,*f2,*f3; int i,n; clrscr(); f1=fopen("Input","w"); printf("\n Enter the contents of a file\n"); for(i=1;i<=10;i++) { scanf("%d",&n); putw(n,f1); } fclose(f1); f1=fopen("Input","r"); f2=fopen("Even","w"); f3=fopen("Odd","w"); while((n=getw(f1))!=EOF) { if((n%2)==0) putw(n,f2); else putw(n,f3); } fclose(f1); fclose(f2); fclose(f3); f1=fopen("Input","r"); printf("\nContents of first file \n"); while((n=getw(f1))!=EOF) { printf("%d\t",n); } fclose(f1); f2=fopen("Even","r"); printf("\n Contents of even file\n"); while((n=getw(f2))!=EOF) { printf("%d\t",n); } fclose(f2);

68

Page 75: First Bsc Lab Record

f3=fopen("Odd","r"); printf("\nContents of oddfile \n"); while((n=getw(f3))!=EOF) { printf("%d\t",n); } fclose(f3); getch(); }

Enter the contents of a file1243678538956

Contents of first file12 4 3 6 78 5 3 8 9 56

Contents of even file12 4 6 78 8 56Contents of oddfile3 5 3 9

69