You are on page 1of 74

DEPARTMENT OF COMPUTER SCIENCE

ENGINEERING -COMPUTER PRACTICE


LABORATORY

YEAR: I (2018-2022) SEMESTER: I

STAFF HANDLING: P.SATHISHKUMAR


EX.NO : 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION

AIM:
To create a document and manipulate the text with specific notations using MS-office.

REQUIREMENTS FOR EXECUTION:

SYSTEM 1

O/S WINDOWS 98

PROCEDURE :

1. Open a new document using File → New option and type text.
2. For justification, select the entire text in the document then press CTRL+J or select the

justify button on the formatting toolbar.


3. For bold facing, select the particular word then press CTRL +B or select the on the
formatting toolbar.

4. To make Italic style, select the particular word then press CTRL +I or select the on
the formatting toolbar.
5. For Underlining , select the particular word then press CTRL +U or select the on
the formatting toolbar.
6. For spelling corrections, select the particular word, then right click the mouse or click
spelling and grammar button on the standard tool bar.

7. For saving the document, press CTRL+S or click on save button on standard tool bar
or select the save option from the File menu.
The above options are commonly used for creating the document. Apart from these, MS-
WORD provides a lot of options for making the document an attractive one.
RESUME

Raghul. V
4/10,Nehru Street, e-mail id : raghul_v@yahoo.co.in
Salem-10. Mobile No.: 9876543210

OBJECTIVE:

To obtain a meaningful and challenging position which will enables me to become a


recognized employee, face the challenges, serve the industry with all my might and to learn and
acquire more practical knowledge.

EDUCATIONAL QUALIFICATION:

 M.E. Computer Science with 8.6 CGPA in V.S.B. Engineering College,Karur.

College,B.E. Computer Science with an aggregate of 73% from V.S.B. Engineering


Karur.

 HSC 2006, with an aggregate of 68% from Cheran school, Karur

 SSLC 2004, with an aggregate of 72% from Cheran school, Karur

SOFTWARE SKILLS:

LANGUAGES : C, C++, JAVA.

PACKAGES : MS-Office

AREA OF INTEREST:

 Data Structure
 Computer Networks

PERSONAL DETAILS:

NAME : Raghul.V

FATHER’S NAME : Vishnu.R


DATE OF BIRTH: 06-03-1988

COMMUNICATION
ADDRESS : 4/10,Nehru Street,
Salem-10.

DECLARATION

I hereby declare that the above details are true to the best of my knowledge.

Yours

/* USE OF SCIENTIFIC NOTATIONS*/


PROCEDURE:

1. Open a new document using File → New option.


2. To create Equation using Scientific Notation, choose Insert →Equation.
3. Type the required equation in the Equation tool using the scientific notations found in
Equation tool→ Design.

4. For saving the document, press CTRL+S or click on save button on standard tool bar
or select the save option from the File menu.
EQUATIONS:

1.

2. + =1

3.
4.

5.

6.

RESULT:
Thus, the given document has been created and manipulated using MS-office.
EX.NO:02 PRESENTATION AND VISUALIZATION – GRAPHS AND CHARTS

AIM:
To prepare the Line, XY, Bar and Pie Charts in MS-Excel.

REQUIREMENTS FOR EXECUTION:

SYSTEM 1

O/S WINDOWS 98

Create examination databases and find the total and average of each student.

RULES: 1. PASS if marks in each subject >= 35.


2. FAIL if marks in any subject < 35.
3. Distinction if average >= 75.
4. First class if average >= 60 but less than 75.
5. Second class if average >= 50 but less than 60.
6. Third class if average >= 35 but less than 50.

PROCEDURE:

1. Enter the given data in worksheet.


2. Choose the chart option from the insert menu, or choose the chart wizard button
from the standard toolbar.

3. Shows the chart wizard step 1 of 4 chart type dialog box.

4. Choose the appropriate chart type from the chart type list box then click next.

5. Shows the chart wizard step 2 of 4 chart source data dialog box, then click next.

6. Shows the chart wizard step 3 of 4 chart options dialog box, here you can give
the Chart title. (i) X and Y axis title etc., then click next.

7. Shows the chart wizard step 4 of 4 chart location dialog box then click finish.
BAR CHART:

OUTPUT:
LINE CHART:

OUTPUT:
XY CHART:

OUTPUT:
PIE CHART:

OUTPUT:

RESULT:
Thus, the various charts has been created successfully.
EX.NO : 3 PROBLEM SOLVING AND FLOWCHARTS

AIM:
To draw a flowchart using drawing toolbar in MS-WORD.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

PROCEDURE :

1. Choose flowchart options in the auto shapes menu of the Drawing Toolbar.

2. Choose the appropriate flowchart symbol and then drag the symbol in the document.

3. Type the text in the symbol, by right click then choose Add Text.

4. Using the Arrow button, Line style button and Arrow Style in the Drawing Toolbar the
lines connecting to the different flowchart symbols.

5. Select all the flowchart symbols and lines in the document using the Select Objects
button, then right choose Grouping, then click on Group.

6. Now all the Flowchart symbols are grouped into one.


SAMPLE FLOWCHART

Start

Read a, b

Yes No
If
a>b

Display Display
a b

Stop

RESULT:

Thus, the given flowchart has been drawn successfully.


EX. NO :4A SIMPLE STATEMENTS AND EXPRESSIONS- DATA TYPES

AIM:
To Write a C program to find the size of the data types.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

OS WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Step-1: Start the program


Step-2: Declare the necessary variables.
Step-3: Print the size of data type for the given variable.
Step-4: Stop the program.
FLOWCHART:

Start

Enter the value of


a,b,c,d

Calculate
sizeof(a);sizeof(a);sizeof(b);
sizeof(c);sizeof(‘c’);sizeof(d)

Display size of a,b,c,d

Stop

SOURCE CODE:

#include<stdio.h>
#include<conio.h>
#include<string.h>

void main()
{
int a;
float b;
char c='U';
char d[10];
clrscr();
printf(“\nENTER THE VALUE OF a,b,c\n”);
printf(“\n\n a=”);
scanf(“%d”,&a);
printf(“\n\n b=”);
scanf(“%f”,&b);
printf("\nEnter character string\n");
printf(“\n\nc=”);
scanf("%s",d);
printf(“\n\n sizeof(%d)=%d bytes”,a,sizeof(a));
printf(“\n\n sizeof(%f)=%d bytes”,b,sizeof(b));
printf(“\n\n sizeof(%c)=%d bytes”,c,sizeof(c));
printf("\n\n sizeof('c')=%d bytes",sizeof('c'));
printf("\n\n sizeof(%s)=%d bytes",d,sizeof(d));
getch();
}

OUTPUT:

ENTER THE VALUE OF a, b, c


a=20
b=10
Enter character string
c=WELCOME
sizeof(10)=2 bytes
sizeof(20.000000)=4 bytes
sizeof(u)=1 bytes
sizeof(‘c’)=2 bytes
sizeof(WELCOME)=20 bytes
EX. NO:4b EXPRESSION EVALUATION
DATE :

AIM:
To Write a C program to evaluate the given expression r = a * (b – c) / d + e.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Step-1: Start the program


Step-2: Declare the necessary variables.
Step-3: Compute the given expression r = a * (b – c) / d + e.
Step-4: Print the result
Step-5: Stop the program.
FLOW CHART:

Start

Enter the value of


a,b,c,d,e

Converting a,b,c,d,e in float


datatype to float of floating
point 2

Calculate
r= a * (b - c) / d + e

Display r

Stop

SOURCE CODE:

#include <stdio.h>
#include <conio.h>

void main()
{
float a,b,c,d,e,r;
clrscr();

printf("\n\n Enter the values of a,b,c,d,e\n\n");


scanf("%f %f %f %f %f",&a,&b,&c,&d,&e);

printf("\n\na = %.2f\n",a);
printf("\n\nb = %.2f\n",b);
printf("\n\nc = %.2f\n",c);
printf("\n\nd = %.2f\n",d);
printf("\n\ne = %.2f\n",e);

printf("\n\na * (b - c) / d + e\n\n");
r = a * (b - c) / d + e;

printf("\n%.2f * (%.2f - %.2f) / %.2f + %.2f = %.2f",a,b,c,d,e,r);


getch();
}

OUTPUT:

Enter the values of a,b,c,d,e


5 2 6 8 9

a = 5.00

b = 2.00

c = 6.00

d = 8.00

e = 9.00

a * (b - c) / d + e

5.00 * (2.00 - 6.00) / 8.00 + 9.00 = 6.50


EX.NO: 4C CONDTIONAL STATEMENT
DATE:

AIM:
To write a C program to check the largest number among given three numbers.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

STEP-1: Start the program.


STEP-2: Declare the necessary variables.
STEP-3: CHECK IF((a > b && a > c)
STEP-3.1: Print A.
STEP-4: Otherwise, check if(b>c)
STEP-4.1: Print B
STEP-5: else print C
STEP-6: Stop.
FLOW CHART:

START

Input a, b, c

TRUE If a>b FALSE


If b>c
&&
a>c
TRUE FALSE

B is great
A is great C is great

Stop

SOURCE CODE:

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,c;
clrscr();

printf("\nEnter any three numbers : ");


scanf("%d %d %d", &a, &b, &c );
if(a > b && a > c)
printf("\n\n %d is the largest number\n",a);
else if(b > c)
printf("\n\n %d is the largest number\n",b);
else
printf("\n\n %d is the largest number\n",c);
getch();
}

OUTPUT:

OUTPUT:1

Enter any three numbers : 10 15 60

60 is the largest number

OUTPUT:2

Enter any three numbers : 20 5 4

20 is the largest number

OUTPUT:3

Enter any three numbers : 20 50 26

50 is the largest number

RESULT:

Thus, the Data type, Expression Evaluation, Conditional Statements has


been executed successfully.
E X. N O : 5 SCIENTIFIC PROBLEM SOLVING USING DECISION MAKING & LOOPING

AIM:

To write a C program to solve scientific problem using decision making and looping.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Start 1: start the program.


Start 2: get the a, b, c values.
Start 3: if a=0 means print error.
Start 4: perform calculation for e=b*b-4*a*c
If e>0 means d=sqrt(e);
Then x1= (-b+d) / (2*a);
X2= (-b-d) / (2*a);
Print the x1, x2 values.
Start 5: else d=sqrt(-e) then
X1=(-b/ 2*a)
X2=d/(2*a)
Start 6: print the x1, x2 values.
Start 7: stop the program.
FLOW CHART:

Start

Read a,b,c

if (a == 0)

Print Error

Perform e

False
If(e>0)

True

d = sqrt(e); d = sqrt(-e);
x1 = (-b + d) / (2. * a); x1 = -b / (2. * a);
x2 = (-b - d) / (2. * a); x2 = d / (2. * a);

Print the x1,x2 values

Stop
SOURCE CODE:

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
int main()
{
double a, b, c, d, e, x1, x2;

/* Read input data */


printf("\na = ");
scanf("%lf", &a);
printf("b = ");
scanf("%lf", &b);
printf("c = ");
scanf("%lf", &c);

/* Test for a = 0. */
if (a == 0.)
{
printf("\nError: a = 0.\n");
exit(1);
}

/* Perform calculation */
e = b * b - 4. * a * c;

if (e > 0.) // Test for real roots


{
/* Case of real roots */
d = sqrt(e);
x1 = (-b + d) / (2. * a);
x2 = (-b - d) / (2. * a);
printf("\nx1 = %12.3e x2 = %12.3e\n", x1, x2);
}
else
{
/* Case of complex roots */
d = sqrt(-e);
x1 = -b / (2. * a);
x2 = d / (2. * a);
printf("\nx1 = (%12.3e, %12.3e) x2 = (%12.3e, %12.3e)\n",
x1, x2, x1, -x2);

}
return 0;
}
OUTPUT:

a=4
b=2
c=5

x1 = ( -2.500e-01, 1.090e+00) x2 = ( -2.500e-01, -1.090e+00)

RESULT:

Thus, the Scientific problem solving using decision making and looping has been
executed successfully.
E X. N O : 6A ONE DIMENSIONAL ARRAY
DATE :

AIM:
To write a C program to implement the one dimensional array.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Step -1: start the program.


Step -2: declare the arrays values.
Step -3: read the array for upto n times.
Step -4: print the values.
Step -5: stop the program.
FLOW CHART:

Start

Enter three numbers

for(i=0; i<3;
i++)

read array a[i]

Print the numbers

for(i=0; i<3;
i++)

print array a[i]

stop
SOURCE CODE:
#include <stdio.h>
#include <conio.h>
void main()
{
int a[3], i;;
clrscr();
printf("\n\t Enter three numbers : ");
for(i=0; i<3; i++)
{
scanf("%d", &a[i]); // read array
}
printf("\n\n\t Numbers are : ");
for(i=0; i<3; i++)
{
printf("\t %d", a[i]); // print array
}
getch();
}

OUTPUT:

Enter three numbers : 9 4 6

Numbers are : 9 4 6
E X. N O : 6B TWO DIMENSIONAL ARRAY - MATRIX MULTIPLICATION

AIM:
To write a C program to implement the Matrix multiplication.

REQUIREMENTS FOR EXECUTION:

SYSTEM 1

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Step-1: Start the program.


Step-2: Declare the necessary variables.
Step-3: Set a loop to get A matrix.
Step-4: Read A matrix value
Step-5: Set a loop to get B matrix.
Step-6: Read B matrix value.
Step-7: Assign c[i][j]=0,Using this formula to calculate the multiplication
matrix c[i][j] = c[i][j] + a[i][k] * b[k][j].
Step-8: Set a loop to print the multiplication matrix value.
Step-9: Stop the program.
FLOWCHART
Start

Declare
a[i][j],b[i][j],c[i][j],i , j, k

Enter
‘A’ Matrix

i=0

j=0

Read

Print ‘\n’

Yes/True
If j<3 J++

False /No

Yes/True
If i<3 I++

False /No
a
a

Enter ‘B’

i=0

j=0

Read

Print ‘\n’

If j<3 Yes/True j++

False /No

If i<3 Yes/True
i++

False /No

Print
MATRIX
MULTIPLICATION

i=0

b
b

j=0

C[i][j]

k=0

C[i][j]=c[i][j]+a[i][j]*b[i][j]

Yes/True
If
k++
k<3

False /No
Yes/True
If j<3 J++

False /No

Yes/True
If i<3 i++

False /No

c
c

i=0

j=0

Display c[i][j]

If j<3 Yes/True
i++

False /No

If i<3 Yes/True
i++

False /No

Print ‘\n’ ’\n’

Stop
SOURCE CODE:

#include<stdio.h>
#include<conio.h>
void main()
{
int a[3][3],b[3][3],c[3][3],i,j,k;
clrscr();
printf("\nENTER 'A'MATRIX\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&a[i][j]);
}
printf("\n");
}
printf("\nENTER 'B'MATRIX\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
scanf("%d",&b[i][j]);
}
printf("\n");
}
printf("__________________________\n\n");
printf("MATRIX MULTIPLICATION\n");
printf("__________________________\n\n");
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
c[i][j]=0;
for(k=0;k<3;k++)
{
c[i][j]=c[i][j]+a[i][k]*b[k][j];
}
}
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
printf("%d\t",c[i][j]);
}
printf("\n\n");
}
getch();
}

OUTPUT:

ENTER 'A'MATRIX

111

222

333

ENTER 'B'MATRIX

123

123

123

__________________________

MATRIX MULTIPLICATION
__________________________

3 6 9

6 12 18

9 18 27

RESULT:
Thus, the given program has been executed successfully.
Ex.No.7a STRING FUNCTIONS-COMPARE TWO STRINGS

AIM:

To write a C program to compare two strings using strcmp().

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Start 1: start the progrm.


Start 2: get the first string.
Start 3: get the second string.
Start 4: using strcmp () function compare the two strings.
Start 5: else prints not equal.
Start 6: stop the program.
FLOW CHART:
SOURCE CODE:

/*** Program to Compare Two Strings using strcmp() ***/


#include <stdio.h>
#include <string.h>
main()
{
char s1[20], s2[20];
int result;
printf("\nEnter first string: ");
gets(s1);
printf("\nEnter second string: ");
gets(s2);
result = strcmp(s1, s2);
if (result == 0)
printf("\nBoth strings are equal");
else
printf("\nBoth strings are not equal");
getch();
}

OUTPUT:

Enter first string: college

Enter second string: engineering

Both strings are not equal


Ex.No.7b STRING FUNCTIONS-CONCATENATE TWO STRINGS

AIM:

To write a C program to concatenate two strings using strcat()

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC
ALGORITHM:

Start 1: start the progrm.


Start 2: get the first string.
Start 3: get the second string.
Satrt 4: using strcat() function to concatenate the string.
Start 5: print the concatenated string.
Start 5: stop:

FLOW CHART:

Start

Read strings
S1,S2

strcat(S1,S2)

Print the string

Stop
SOURCE CODE:

/**** Program to Concatenate Two Strings using strcat() ****/


#include <stdio.h>
#include <string.h>
main()
{
char s1[20], s2[20];
printf("\nEnter first string: ");
gets(s1);
printf("\nEnter second string: ");
gets(s2);
strcat(s1, s2);
printf("\nThe concatenated string is: %s", s1);
getch();
}

OUTPUT:

Enter first string: Collegeof

Enter second string: Engineering

The concatenated string is: Collegeof Engineering


Ex.No.7c STRING FUNCTIONS-COPY THE STRING

AIM:

To write a C program to copy the strings using strcpy()

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Start 1: start the program.


Start 2: get the string.
Start 3: copy the string into another string variable by using strcpy() fucntion
Start 4: print the string.
Start 5: stop the program
FLOW CHART:

Start

Read string
S1
Strcpy

strcpy(S2,S1)

Print the string


S2

Stop

SOURCE CODE:

/*** Program to Copy String using strcpy() ***/


#include <stdio.h>
#include <string.h>
main()
{
char s1[20], s2[20];
printf("\nEnter string into s1: ");
gets(s1);
strcpy(s2, s1);
printf("\ns2: %s", s2);
getch();
}
OUTPUT:

Enter string into s1: Engineering

s2: Engineering
Ex.No.7d STRING CONVERTION TO LOWER CASE,UPPERCASE, STRING LENGTH

AIM:

To write a C program to convert the strings to lower case, upper case, find string length.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Start 1: start the program.


Start 2: get the string.
Start 3: using strlwr() fucntion to convert the lower case of the string.
Start 4: print the lower string.
Start 5: using strupr() fucntion to convert theupper case of the string.
Start 6: print the upper string.
Start 7: using strrev() fucntion to convert the reverse order of the string.
Start 8: using strlen() function to find the length of the string.
Strat 9: print the string.
Start 10: stop the program.

FLOW CHART:

Start

Read the
string

S1=strlwr(s)
S2=strupr(s)
S3=strrev(s)
N=strlen(s)
Print S1,S2,S3,N

Stop

SOURCE CODE:

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
char str[50];
clrscr();
printf("\n\t Enter your name : ");
gets(str);
printf("\nLower case of string: %s",strlwr(str));
printf("\nUpper case of string: %s",strupr(str));
printf("\nReverse of string: %s",strrev(str));
printf("\nLength of String: %d",strlen(str));
getch();
}

OUTPUT:

Enter your name : Colllege

Lower case of string: colllege


Upper case of string: COLLLEGE
Reverse of string: EGELLLOC
Length of String: 8

RESULT:
Thus, the given program has been executed successfully.
Ex.No.8 USER DEFINED FUNCTIONS-SWAPPING OF TWO NUMBERS

AIM:

To write a C program to swap two numbers using pointers.

REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

1. Declare the two pointer variables.


2. Get the value for both the variables.
3. Swap the values.
4. Print the result.
FLOW CHART:

Start

Initialize the function

Read a, b

Print values a, b before Define swap


swapping

Calling Start

Print values a, b after swapping

Stop
SOURCE CODE:

#include<stdio.h>
#include<conio.h>
void swap(int *,int *);
void swap1(int,int);
void main()
{
int a,b,c,d;
clrscr();
printf("Enter the values of a and b:= ");
scanf("%d %d",&a,&b);
printf("Enter the values of c and d:= ");
scanf("%d %d",&c,&d);
printf("\n BEFORE SWAPPING : ");
printf("\n The value of a and b is : %d\t %d ",a,b);
printf("\n The value of c and d is : %d\t %d ",c,d);
printf("\n AFTER SWAPPING : ");
swap(a,b);
swap1(&c,&d);
printf("\n Method is:-Call by Value");
printf("\n **************************");
printf("\n The value of a and b is : %d\t %d",a,b);
printf("\n Method is:-Call by Address or Reference");
printf("\n ***************************");
printf("\n The value of c and d is : %d\t %d",c,d);
getch();
}
void swap(int *c,int *d)
{
int t;
t=*c;
*c=*d;
*d=t;
}
void swap1(int a,int b)
{
int t;
t=a;
a=b;
b=a;
}

OUTPUT:

Enter the values of a and b: = 2 4


Enter the values of c and d: = 6 5

BEFORE SWAPPING:
The value of a and b is: 2 4
The value of c and d is: 6 5

AFTER SWAPPING:
Method is:-Call by Value
The value of a and b is: 2 4
Method is:-Call by Address or Reference
The value of c and d is: 5

RESULT:
Thus, the given program has been executed successfully.
EX.NO:9A
RECURSIVE FUNCTIONS -FIBONACCI SERIES

AIM:
To write a program in C
i) To print the Fibonacci series
REQUIREMENTS FOR EXECUTION:

1
SYSTEM

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

Step-1:Start
Step-2:Read the input variable ‘n’
Step-3:Call function fib(n)
Step-4:Stop.

FUNCTION:

Step-1:a=0,b=1
Step-2:print a, b
Step-3:for(i=0;i<n;i++)
Step-3-1:c=a+b
Step-3-2:a=b
Step-3-3:b=a
Step-3-4:prin c
Step-4:stop

FLOW CHART:
START

Enter Fibonacci
Limit, n

Initialize a=0,b=1

print a,b

NO/FALSE
Initialize i=0

If i<n

STOP
YES/TRUE

calculate
c=a+b;
a=b;
b=c;
i++

print c
SOURCE CODE:

#include<stdio.h>
#include<conio.h>

void main()
{
int a,b,n;
clrscr();
printf("\n Enter the Fibonacci Series Limit\n");
scanf("%d",&n);
fib(n);
getch();
}
int fib(int n)
{
int a,b,c,i;
a=0;
b=1;
printf("\n FIBONACCI SERIES\n");
printf("\n%d\n%d",a,b);
for(i=0;i<n;i++)
{
c=a+b;
a=b;
b=c;
printf("\n%d",c);
}
return 0;
}

OUTPUT:

Enter Fibonacci Series Limit:5

FIBONACCI SERIES:

0 1 1 2 3
EX.NO:9B
RECURSIVE FUNCTIONS –FACTORIAL OF A NUMBER

AI M:
To write a C program to find the factorial of a given number.
REQUIREMENTS FOR EXECUTION:

SYSTEM 1

O/S WINDOWS 98

COMPILER TURBOC

ALGORI THM
1. Start the program.
2. Declare the necessary variables.
3. Get the number from user to find the factorial.
4. Write a user defined function for factorial using the formula n*fact (n-1).
5. Print the factorial of the given number.
6. Stop the program.
FLOW CHART:

SOURECE CODE:
#include<stdio.h>
#include<conio.h>
void main()
{
int fact(int);
int n,f,choice;
clrscr();
printf(“Enter the number to find the factorial\n”);
scanf(“%d”,&n);
f=fact(n);
printf(“The factorial of a number %d using recursion is %d”,n,f);
getch();
}
int fact(int n)
{
int f;
if(n==0)
return(1);
else
f=n*fact(n-1);
return(f);
}

OUTPUT
Enter the number to find the factorial
5
The factorial of a number 5 using recursion is 120

RESULT:
Thus, the given program has been executed successfully.
EX.NO:10A PROGRAM FOR STRUCTURE

AIM:
To prepare the mark sheet of ‘n’ students using structures and to write a C program using
Structure.

REQUIREMENTS FOR EXECUTION:

SYSTEM 1

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

STEP-1: Start the program.


STEP-2: Defining the structure student with members.
STEP-3: Declare the necessary variables.
STEP-4: Set a loop to get the details of student mark list
STEP-5: Read the student details.
STEP-6: Total the marks, and to calculate the average of students mark.
STEP-7: Check the conditions.
STEP-8: Set a loop to print the mark list
STEP-9: Stop.
FLOWCHART:
Start

Initialize i, n

ENTER THE
VEALUE OF n

Read n
a

ENTER NAME, RNO


AND MARKS

i=0

Read Name, R.No,


m1,m2,m3

YES/TRUE
If i++
i<n
NO/FALSE
Print STUDENT
DETAILS

i=0

c[i].tot=c[i].m1+c[i].m2+c[i].m3+c[i].m4;
c[i].avg=(c[i].tot)/4;
Print Name, R.No,
m1,m2,m3, tot, avg

YES/TRUE
If i++
i<n

NO/FALSE
SOURCE CODE:
Stop
#include<stdio.h>
#include<conio.h>

struct student
{
char name[20];
int rno;
}s;
struct cse
{
int m1;
int m2;
int m3;
int m4;
int tot;
float avg;
struct student s;
}c[10];
void main()
{
int i,n;
clrscr();
printf("ENTER THE VEALUE OF n\n\n");
scanf("%d",&n);
printf("\nENTER NAME,RNO AND MARKS \n\n");
for(i=0;i<n;i++)
{
scanf("%s%d",c[i].s.name, &c[i].s.rno);
scanf("%d",&c[i].m1);
scanf("%d",&c[i].m2);
scanf("%d",&c[i].m3);
scanf("%d",&c[i].m4);
}
printf("\n\n\n");
printf("\t\t******************STUDENT DETAILS***************\n");
printf("\t------------------------------------------------------------------\n");
printf("\tNAME\tRNO\tM1\tM2\tM3\tM4\tTOTAL\tAVERAGE\n");
printf("\t------------------------------------------------------------------\n");
for(i=0;i<n;i++)
{
c[i].tot=c[i].m1+c[i].m2+c[i].m3+c[i].m4;
c[i].avg=(c[i].tot)/4;
printf("\t%s\t%d\t%d\t%d\t%d\t%d\t%d\t%.2f\n\n",c[i].s.name,c[i].s.rno,c[i].m1,
c[i].m2,c[i].m3,c[i].m4,c[i].tot,c[i].avg);
}
printf("\t------------------------------------------------------------------\n");
getch();
}

OUTPUT:

ENTER THE VEALUE OF n


2

ENTER NAME,RNO AND MARKS

Sugir
23
95
85
85
95

Jai
12
98
98
78
98
***********************STUDENT DETAILS******************
---------------------------------------------------------------------------------------
NAME RNO M1 M2 M3 M4 TOTAL AVERAGE
----------------------------------------------------------------------------------------
Sugi 23 95 85 85 95 360 90.00

Jai 12 98 98 78 98 372 93.00


EX.NO:10B PROGRAM FOR UNION

AIM:
To prepare the mark sheet of ‘n’ students using structures and to write a C program using
Union.

REQUIREMENTS FOR EXECUTION:

SYSTEM 1

O/S WINDOWS 98

COMPILER TURBOC

ALGORITHM:

STEP-1: Start the program.


STEP-2: Defining the Union student with members.
STEP-3: Declare the necessary variables
STEP-5: Read the values declared for the variables.
STEP-6: Using reference the value is declared to the variables.
STEP-7: Display the values.
Step-8 : Print the result.
Step-9 : Stop.

FLOWCHART:

Start

Int a; Char b[2];

c.a=256

www.Vidyarthiplus.com
www.Vidyarthiplus.com

Print c.a

Print c.b[0]

Print c.b[1]

SOURCE CODE: Stop

#include<stdio.h>
#include<conio.h>
union student
{
int a;
char b[2];
}c;
void main()
{
c.a=256;
printf(“\n Values Of c.a is = %d” ,c.a);
print(“\n Values Of c.b[0]=%d”,c.b[0]);
printf(“\n Values Of c.b[1]=%d”,c.b[1]);
getch();
}

OUTPUT:

Value Of c.a is = 256


Value Of c.b[0] = 0
Value Of c.b[1] = 1

RESULT:
Thus, the given program has been executed successfully.

www.Vidyarthiplus.com

You might also like