Académique Documents
Professionnel Documents
Culture Documents
TECHNOLOGY
COLLEGE ROAD, KUTTAKUZHI, VEEYANNOOR POST,
NAME
: :
REGISTER NO :
DEPARTMENT :
BONAFIDE CERTIFICATE
Page
Ex No Date Name of the Experiment Sign
No
1b Creating Advertisement 3
3 Drawing Flowchart 12
6a Fibonacci Series 26
7b Matrix Multiplication 35
7c Sorting 37
9a Swapping 41
Aim
To create a document that includes some equations and text with bullets and
numbering in OpenOffice Writer.
Procedure
1
Output
− b± √b2 − 4ac
2a
Civil Engineering
Computer Science and Engineering
Electrical and Electronics Engineering
Electronics and Communication Engineering
Information Technology
Mechanical Engineering
Result
The OpenOffice Writer document was created with equations and text with bullets
and numbering successfully and verified.
2
Ex.No. 1(b)
Creating Advertisement
01-09-2015
Aim
Procedure
3
Output
Result
4
Ex.No. 2(a)
Creating Spread Sheet Chart
09-09-2015
Aim
To generate different types of charts to analyze the marks of the students of a class
using OpenOffice Calc.
Procedure
5
Output
Charts
Column Chart
Mark Statement
2015-2016 ODD
120
100
80 Physics
Chemistry
Marks
60
Maths
40
20
0
Arvinth Arjun Arul Anish Alex
Student Names
Bar Chart
Mark Statement
2015-2016 ODD
Alex
Anish
Physics
Student Name
Chemistry
Arul
Maths
Arjun
Arvinth
0 20 40 60 80 100 120
Marks
6
Line Chart
Mark Statement
2015-2016 ODD
120
100
80 Physics
Chemistry
Marks
60
Maths
40
20
0
Arvinth Arjun Arul Anish Alex
Student Name
Net Chart
Mark Statement
2015-2016 ODD
Arvinth
100
50 Physics
Arjun Alex Chemistry
Marks
Maths
0
Arul Anish
Student Name
Result
The spreadsheet for generating different types of charts to analyze the marks of the
students of a class using OpenOffice Calc was created successfully and verified.
7
Ex.No. 2(b)
Mark List Preparation Using Formulae
09-09-2015
Aim
To prepare the Mark list of students by applying formulas using OpenOffice Calc.
Procedure
8
Output
Result
The spreadsheet for preparing the Mark list of students by applying formulas using
OpenOffice Calc was created successfully and verified.
9
Ex.No. 2(c)
Simple Sorting Using Spreadsheet
09-09-2015
Aim
Procedure
10
Output
Before Sorting
Sorting Selection
After Sorting
Result
The spreadsheet for sorting a set of names and numbers using OpenOffice Calc was
created successfully and verified.
11
Ex.No. 3
Drawing Flowchart
16-09-2015
Aim
Procedure
12
Output
START
Read a, b
Is a>b
Yes No
Print a Print b
STOP
13
Flowchart for Largest of three numbers
START
Read a, b, c
Is
a>b
Is Is
b>c a>c Yes
Yes No No
STOP
14
Flowchart for Factorial of a given number
START
Input N
Fact = 1
No Yes
For i=1 to
N
Fact = Fact * i
Print Fact
STOP
15
Flowchart for Area and Circumference of Circle
START
Input r
Print Area,
Circumference
STOP
16
Flowchart for finding Odd or Even number
START
Input n
Num=n%2
If Num==0
STOP
Result
The document for creating flowcharts in OpenOffice Writer was created successfully
and verified.
17
Ex.No. 4
Letter Preparation Using Mail Merge
Aim
Procedure
18
Output
From
To
Dr.C.P.Jesuthanam,
Narayanaguru College of Engineering,
Manjalumoodu.
629151
Dear Sir,
Thanking you,
19
From
To
Dr.T.R.Sethuraman,
Sivaji College of Engineering and Technology,
Manivilai.
695504
Dear Sir,
Thanking you,
Result
The document for creating letters using mail merge option in OpenOffice Writer was
created successfully and verified.
20
PROCEDURE TO EXECUTE THE C PROGRAM IN LINUX
1. Create a folder in Documents. [ex : GE6161]
2. Open the folder. [ex : GE6161]
3. Right Click in the folder and create a new file as filename.c [ex : largest.c]
4. After creating the file, type the program in the file and save.
5. After saving the file you have to execute the file C program.
6. To execute the file navigate to the Terminal command line from Application menu.
7. In the terminal menu input the commands.
cd Documents
Then press the Enter key.
cd GE6161
Then press the Enter key.
8. To Compile the program use the command:
gcc –o <filename> <filename.c> [ex: gcc –o largest largest.c]
If any errors are there in the program the error message will be displayed else the
command line will be displayed.
9. To execute / run the program:
./filename [ex: ./largest]
10. The output will be displayed in the terminal command line.
21
Ex.No. 5(a)
Largest Among Three Numbers
Aim
To write a program to find the largest among three given numbers.
Algorithm
#include<stdio.h>
main()
{
int a,b,c;
printf("Enter the three numbers:\n");
scanf("%d%d%d",&a,&b,&c);
if((a>b)&&(a>c))
{
printf("%d is the largest number",a);
}
else if(b>c)
{
printf("%d is the largest number",b);
}
else
{
printf("%d is the largest number",c);
}
}
Output
Aim
Algorithm
Program
#include<stdio.h>
main()
{
float r,area,circum;
printf("\nEnter the radius of the circle:");
scanf("%f",&r);
area=3.14*r*r;
circum=2*3.14*r;
printf("\nArea=%f\n",area);
printf("\nCircumference=%f\n",circum);
}
Output
Result
The program to find the area and circumference of a circle was written and executed.
23
Ex.No. 5(c)
Checking Leap Year
Aim
To write a program to find whether the given year is leap year or not.
Algorithm
Program
#include<stdio.h>
main()
{
int ye;
printf("Enter the year ");
scanf("%d",&ye);
if(ye%4==0)
printf("It is a leap year\n");
else
printf("It is not a leap year\n");
}
Output
Enter the year 2016
It is a leap year
Enter the year 2015
It is not a leap year
Result
The program to find whether the given year is leap year or not was written and
executed.
24
Ex.No. 5(d)
Menu Driven Calculator Program Using Switch
Aim
Algorithm
Program
#include<stdio.h>
void main()
{
int a,b,sum,sub,mul,div,n;
printf("Enter the values of a and b\n");
scanf("%d%d",&a,&b);
printf("1.Addition\n2.Subtration\n3.Multiplication\n4.Division");
printf("Enter your choice : ");
scanf("%d",&n);
switch(n)
{
case 1:
sum=a+b;
printf("Addition is: %d",sum);
break;
case 2:
sub=a-b;
printf("Subtraction is:%d",sub);
break;
case 3:
mul=a*b;
printf("Multiplication is:%d",mul);
25
break;
case 4:
div=a/b;
printf("Division is:%d",div);
break;
default:
printf("invalid choice");
break;
}
}
Output
1. Addition
2. Subtraction
3. Multiplication
4. Division
1. Addition
2. Subtraction
3. Multiplication
4. Division
Result
The program for menu driven calculator using switch statement was written and
executed.
26
Ex.No. 6(a)
Fibonacci Series
Aim
Algorithm
Step-1:Start
Step-2:Read the input variable „n‟
Step-3:Call function fib(n)
Step-4:Stop.
Program
#include<stdio.h>
void main()
{
int num,fib=0,a=0,b=1,i;
printf("Enter the number\n");
scanf("%d",&num);
printf("\n Fibonacci Series\n");
if(num==0)
printf("0");
else
{
for(i=0;i<num;i++)
{
fib=fib+a;
a=b;
b=fib;
printf("%d\n",fib);
}
}
}
27
Output
Fibonacci Series
0
1
1
2
3
Result
The program to generate the Fibonacci series was written and executed.
28
Ex.No. 6(b)
Finding Sum of Digits And Checking Palindrome
Aim
Algorithm
Step-1: Start
Step-2: Read the input values
Step-3: check the while condition
Step-4: print the output
Step-5: Stop.
Program
#include<stdio.h>
main()
{
unsigned long int a,num,sum=0,rnum=0,rem;
printf("\nEnter the number...");
scanf("%ld",&num);
a=num;
while(num!=0)
{
rem=num%10;
sum=sum+rem;
rnum=rnum*10+rem;
num=num/10;
}
printf("\nThe sum of the digits of %ld is %ld\n",a,sum);
printf("\nThe reverse of the number %ld is %ld\n",a,rnum);
if(a==rnum)
printf("\nThe given number is a palindrome\n");
else
printf("\nThe given number is not a palindrome\n");
}
29
Output
Result
The program to find the sum of digits and checking palindrome was written and
executed.
30
Ex.No. 6(c)
Finding Prime Number
Aim
Algorithm
Step-1: Start
Step-2: Assign i=2
Step-3: Read the num values
Step-4: check the condition (num%i=0) means not prime
Step 5: if(i==num) means print prime
Step-6: Stop.
Program
#include<stdio.h>
main()
{
int num,i=2;
printf("Enter the number...");
scanf("%d",&num);
while(i<=num-1)
{
if(num%i==0)
{
printf("The given number is not a prime number\n");
break;
}
i++;
}
if(i==num)
printf("The given number is a prime\n");
}
31
Output
Result
The program to find the given number is prime or not was written and executed.
32
Ex.No. 7(a)
Matrix Addition and Subtraction
Aim
Algorithm
Program
#include<stdio.h>
void main()
{
int a[25][25],b[25][25],c[25][25], d[25][25],i,j,m,n;
printf("Enter the rows and columns of two matrixes..\n");
scanf("%d %d",&m,&n);
printf("\nEnter the elements of A matrix...\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
}
printf("\nEnter the elements of B matrix..\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
scanf("%d",&b[i][j]);
}
printf("\nThe elements of A matrix");
for(i=0;i<m;i++)
{
33
printf("\n");
for(j=0;j<n;j++)
printf("\t%d",a[i][j]);
}
printf("\nThe elements of B matrix");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
printf("\t%d",b[i][j]);
}
printf("\nThe addition of two matrixes");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
{
c[i][j]=a[i][j]+b[i][j];
printf("\t%d",c[i][j]);
}
}
{
printf("\nThe subtraction of two matrixes");
for(i=0;i<m;i++)
{
printf("\n");
for(j=0;j<n;j++)
{
d[i][j]=a[i][j]-b[i][j];
printf("\t%d",d[i][j]);
}
}
}
}
34
Output
Result
The program to perform matrix addition and subtraction was written and executed.
35
Ex.No. 7(b)
Matrix Multiplication
Aim
Algorithm
Program
#include<stdio.h>
void main()
{
int a[10][10],b[10][10],d[10][10];
int i,j,p,q,m,n,k;
printf("Enter size of the A matrix\n");
scanf("%d%d",&p,&q);
printf("Enter size of the B matrix\n");
scanf("%d%d",&m,&n);
if(p==n)
{
printf("Enter the elements of A matrix.\n ");
for(i=0;i<p;i++)
{
for(j=0;j<q;j++)
scanf("%d",&a[i][j]);
}
printf("Enter elements of B matrix. \n ");
for(i=0;i<m;i++)
{
for(j=0;j<m;j++)
36
scanf("%d",&b[i][j]);
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
d[i][j]=0;
for(k=0;k<p;k++)
d[i][j]=d[i][j]+a[i][k]*b[k][j];
}
}
printf("Multiplication of A and B matrix:\n");
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
printf("%5d ",d[i][j]);
printf("\n");
}
}
else
printf("The no.of rows and columns should not be equal");
}
Output
19 22
43 50
Result
37
Ex.No. 7(c)
Sorting
Aim
To write a program to sort a given set of numbers in ascending and descending order.
Algorithm
Step-1: Start
Step-2: Read the input values num, no, i, j
Step-3: Repeat for i=0 to no
Step-4: Repeat for j=i+1 to no
Step-5: Check whether the condition num[i] < num[j]
Step-6: Repeat for i=0 to no, print ascending order
Step-7: Repeat for j=n0-1 to 0, print descending order
Step-8: Stop.
Program
#include<stdio.h>
main()
{
int num[100],no,i,j,a;
printf("Enter upper limit....");
scanf("%d",&no);
printf("Enter the numbers\n");
for(i=0;i<no;i++)
scanf("%d",&num[i]);
for(i=0;i<no-1;i++)
{
for(j=i+1;j<no;j++)
{
if(num[i]<num[j])
{
a=num[i];
num[i]=num[j];
num[j]=a;
}
}
}
printf("\nThe ascending order of the given numbers");
for(i=0;i<no;i++)
printf("\n%d",num[i]);
38
printf("\n The descending number of the given numbers");
for(j=no-1;j>=0;j--)
printf("\n%d",num[j]);
}
Output
Result
The program to sort a given set of numbers in ascending and descending order was
written and executed.
39
Ex.No. 8
String Length and Concatenation
Aim
Algorithm
Program
#include <stdio.h>
#include <string.h>
int main()
{
char a[1000], b[1000];
int length;
printf("Enter the first string\n");
scanf("%s",a);
length = strlen(a);
printf("Length of entered string is = %d\n",length);
printf("Enter the second string\n");
scanf("%s",b);
length = strlen(b);
printf("Length of entered string is = %d\n",length);
strcat(a,b);
printf("String obtained on concatenation is %s\n",a);
return 0;
}
40
Output
Result
The program to find the string length and concatenation of string was written and
executed.
41
Ex.No. 9(a)
Swapping
Aim
Algorithm
#include<stdio.h>
main()
{
int x,y;
printf("\nEnter the two number ...\n");
scanf("%d%d",&x,&y);
printf("\nThe entered number for x and y are, x=%d\ty=%d",x,y);
display(&x,&y);
printf("\nAfter the swapping the value of, x=%d\ty=%d\n",x,y);
}
display(int *a,int *b)
{
int t;
t=*a;
*a=*b;
*b=t;
}
Output
Result
The program to swap two numbers using functions was written and executed.
42
Ex.No. 9(b)
Function Without Arguments and No Return Value
Aim
Algorithm
#include<stdio.h>
void main()
{
void message(void);
message();
}
void message()
{
char str[100];
printf("\nEnter A String..");
scanf("%s", str);
printf("The Given String Is:%s", str);
Output
Enter A String..MACET
The Given String Is:MACET
Result
The program to illustrate function without arguments and no return value was written
and executed.
43
Ex.No. 9(c)
Function With Arguments and No Return Value
01-09-2015
Aim
Algorithm
#include<stdio.h>
void main()
{
int a,b;
printf("\nENTER TWO NUMBERS....\n");
scanf("%d%d",&a,&b);
add(a,b);
}
add(int a, int b)
{
int c;
c=a+b;
printf("%d+%d=%d",a,b,c);
}
Output
Result
The program to illustrate function with arguments and no return value was
written and executed.
44
Ex.No. 9(d)
Function With Arguments and Return Value
01-09-2015
Aim
Algorithm
#include<stdio.h>
void main()
{
int num,a;
printf("\nEnter the Number:");
scanf("%d",&num);
a=recur(num);
printf("The Factorial of the number %d is:%d",num,a);
}
recur(int no)
{
int fact=1;
if(no==1)
return(1);
else
fact=no*recur(no-1);
}
Output
Result
The program to illustrate function with arguments and return value was written and
executed.
45
Ex.No. 9(e)
Function Without Arguments and With Return Value
01-09-2015
Aim
To write a program to illustrate function without arguments and with return value
Algorithm
#include<stdio.h>
#include<string.h>
void main()
{
int l;
int strf();
l=strf();
printf("\nThe given string length is:%d",l);
}
int strf()
{
char str1[100];
int len;
printf("\nEnter the string....");
scanf("%s",str1);
return(len=strlen(str1));
}
Output
Result
The program to illustrate function with arguments and with return value was
written and executed.
46
Ex.No. 10
Factorial of a Given Number Using Recursion
01-09-2015
Aim
Algorithm
#include<stdio.h>
long factorial(int);
int main()
{
int n;
long f;
printf("Enter an integer to find factorial\n");
scanf("%d", &n);
if (n < 0)
printf("Negative integers are not allowed.\n");
else
{
f = factorial(n);
printf("%d! = %ld\n", n, f);
}
return 0;
}
long factorial(int n)
{
if (n == 0)
return 1;
else
return(n * factorial(n-1));
}
47
Output
Result
The program to find the factorial of a given number using recursion was written and
executed.
48
Ex.No. 11(a)
Displaying Marks of Students Using Structure
01-09-2015
Aim
Algorithm
49
Program
#include<stdio.h>
struct student
{
int rno;
char name[10];
int m1,m2,tot;
float avg;
};
void main()
{
struct student s[10];
int n,i;
printf("Enter the no of student : ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("For %d student\n",i+1);
printf("Enter the rno of student : ");
scanf("%d",&s[i].rno);
printf("Enter the name of student : ");
scanf("%s",s[i].name);
printf("Enter the mark1 of student : ");
scanf("%d",&s[i].m1);
printf("Enter the mark2 of student : ");
scanf("%d",&s[i].m2);
}
for(i=0;i<n;i++)
{
s[i].tot=s[i].m1+s[i].m2;
s[i].avg=s[i].tot/2;
}
printf("\n\nDisplaying information of students :: ");
printf("\nRoll No\tName\tMark 1 \tMark 2\tTotal\tAverage");
for(i=0;i<n;i++)
{
printf("\n%d\t%s\t%d\t%d\t%d\t%f\t",s[i].rno,s[i].name,s[i].m1,s[i].m2,s[i].tot,s[i].av
g);
}
}
50
Output
For 1 student
Enter the rno of student : 1
Enter the name of student : Arvind
Enter the mark1 of student : 55
Enter the mark2 of student : 66
For 2 student
Enter the rno of student : 2
Enter the name of student : Arun
Enter the mark1 of student : 45
Enter the mark2 of student : 89
For 3 student
Enter the rno of student : 3
Enter the name of student : Raja
Enter the mark1 of student : 78
Enter the mark2 of student : 89
For 4 student
Enter the rno of student : 4
Enter the name of student : Ramesh
Enter the mark1 of student : 59
Enter the mark2 of student : 89
For 5 student
Enter the rno of student : 5
Enter the name of student : Vishal
Enter the mark1 of student : 92
Enter the mark2 of student : 96
Result
The program to display the marks of students using structure was written and
executed.
51
Ex.No. 11(b)
Program Using Union
01-09-2015
Aim
Algorithm
#include <stdio.h>
union item
{
int a;
float b;
char ch;
};
int main( )
{
union item it;
it.a =1101004922;
it.b = 20.000233;
it.ch='z';
printf("%d\n",it.a);
printf("%f\n",it.b);
printf("%c\n",it.ch);
return 0;
}
Output
1101004922
20.000233
z
Result
52