ex.no: 1 document creation, search, text manipulation …

61
EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION AIM: To create a document and manipulate the text with specific notations using MS-office.

Upload: others

Post on 05-Feb-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

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

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

AIM:

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

Page 2: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESUME

Raghul. V Mobile No.: 9876543210

4/10, Nehru Street, Salem-10. E-mail id: [email protected].

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.

B.E. Computer Science with an aggregate of 73% from V.S.B. Engineering College, 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:

PERSONAL DETAILS:

NAME : Raghul.V

FATHER’S NAME : Vishnu.R

DATE OF BIRTH : 06-03-1988

DECLARATION

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

Yours

Raghul.V

Page 3: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

/* 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:

RESULT:

Thus, the given document has been created and manipulated using MS-office.

Page 4: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX.NO:02 PRESENTATIONS AND VISUALIZATION – GRAPHS AND CHARTS

AIM:

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

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.

Page 5: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 6: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 7: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 8: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 9: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

Thus, the various charts has been created successfully.

Page 10: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX.NO: 3 PROBLEM SOLVING AND FLOWCHARTS

AIM:

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

PROCEDURE:

Procedure:

1. To create a document , select File menu bar then choose New option

2. Choose the flowchart option in the auto shapes menu from the drawing tool bar

3. Select the flowchart symbols from auto shapes

Start / Terminate

Input

Process

Loop / Preparation

Flow Lines / Arrows

Decision

Connector

4. After finishing the entire flowchart select all the flowchart symbols and arrows right click and

click Grouping.

5. Save the document

Page 11: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

SAMPLE FLOWCHART

RESULT:

Thus, the given flowchart has been drawn successfully.

Page 12: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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

AIM:

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

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.

Page 13: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 14: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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

Page 15: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX. NO: 4b EXPRESSION EVALUATION

AIM:

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

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.

Page 16: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 17: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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

Page 18: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX.NO: 4C CONDTIONAL STATEMENT

AIM:

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

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.

Page 19: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 20: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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

Page 21: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

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

successfully.

Page 22: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX. NO: 5 SCIENTIFIC PROBLEMS SOLVING USING DECISION MAKING &

LOOPING

AIM:

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

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.

Page 23: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 24: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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);

}

Page 25: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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)

Page 26: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

Thus, the Scientific problem solving using decision making and looping has been executed

successfully.

Page 27: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX. NO: 6A ONE DIMENSIONAL ARRAY

AIM:

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

ALGORITHM:

Step -1: start the program.

Step -2: declare the arrays values.

Step -3: read the array for up to n times.

Step -4: print the values.

Step -5: stop the program.

Page 28: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

FLOW CHART:

Page 29: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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

Page 30: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX. NO: 6B TWO DIMENSIONAL ARRAYS - MATRIX MULTIPLICATION

AIM:

To write a C program to implement the Matrix multiplication.

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.

Page 31: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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++)

Page 32: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

{

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

{

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

}

printf("\n\n");

}

getch();

}

OUTPUT:

ENTER 'A'MATRIX

1 1 1

2 2 2

3 3 3

ENTER 'B'MATRIX

1 2 3

1 2 3

1 2 3

__________________________

MATRIX MULTIPLICATION

__________________________

3 6 9

6 12 18

9 18 27

Page 33: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

Thus, the given program has been executed successfully.

Page 34: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

Ex.No.7a STRING FUNCTIONS-COMPARE TWO STRINGS

AIM:

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

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.

Page 35: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 36: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

/*** 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

Page 37: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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

AIM:

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

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.

Page 38: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

/**** 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

Page 39: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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

AIM:

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

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

Page 40: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …
Page 41: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

/*** 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

Page 42: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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.

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.

Page 43: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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

Page 44: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

Thus, the given program has been executed successfully.

Page 45: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

Ex.No.8 USER DEFINED FUNCTIONS-SWAPPING OF TWO NUMBERS

AIM:

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

ALGORITHM:

1. Declare the two pointer variables.

2. Get the value for both the variables.

3. Swap the values.

4. Print the result

.

Page 46: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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;

Page 47: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

*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

Page 48: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

Thus, the given program has been executed successfully.

Page 49: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX.NO:9A RECURSIVE FUNCTIONS -FIBONACCI SERIES

AIM:

To write a program in C

a. To print the Fibonacci series

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

Page 50: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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;

Page 51: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

b=c;

printf("\n%d",c);

}

return 0;

}

OUTPUT:

Enter Fibonacci Series Limit:5

FIBONACCI SERIES:

0 1 1 2 3

Page 52: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

EX.NO:9B RECURSIVE FUNCTIONS –FACTORIAL OF A NUMBER

AI M:

To write a C program to find the factorial of a given number.

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.

Page 53: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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

Page 54: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

Thus, the given program has been executed successfully.

Page 55: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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.

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.

Page 56: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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);

Page 57: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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();

}

Page 58: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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

Page 59: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

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.

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.

Page 60: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

PROGRAM:

#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

Page 61: EX.NO: 1 DOCUMENT CREATION, SEARCH, TEXT MANIPULATION …

RESULT:

Thus, the given program has been executed successfully.