1
CONTENTS
EXP. PAGE
DATE TITLE OF EXPERIMENT REMARKS
NO NO
FAMILIARIZATION OF CONSOLE I/O AND
1
OPERATORS IN C
2 LARGEST NUMBER AMONG 3 INTEGERS
3 PRIME NUMBER
4 ARMSTRONG NUMBER
SUM AND AVERAGE OF AN ARRAY OF
5
NUMBERS
6 LINEAR SEARCH
7 BUBBLE SORTING
8 PALINDROME
9 STRING OPERATIONS
10 EUCLIDEAN DISTANCE
11 DATA MANIPULATION USING STRUCTURE
12 DATA MANIPULATION USING UNION
13 FACTORIAL
STRING REVERSAL USING USER DEFINED
14
FUNCTION
15 MATRIX
16 POINTERS
17 FILE OPERATIONS
2
EXP. NO: 1 FAMILIARIZATION OF CONSOLE I/O AND
__/__/2024 OPERATORS IN C
AIM
To familiarize console I/O and operators in C by
1. Displaying “Hello World”
2. Reading two numbers, add them and display their sum
3. Reading the radius of a circle, calculate its area and display it
4. Evaluating the arithmetic expression ((a -b / c * d + e) * (f +g)) and display its solution.
Read the values of the variables from the user through console.
PROGRAM
1. Program to display “Hello World”
/* Display "Hello World" */
#include<stdio.h>
int main ()
{
printf("Hello World");
return 0;
}
2. Program to Read two numbers, add them and display their sum.
/* Read two numbers, add them and display their sum */
#include<stdio.h>
int main()
{
int a, b, sum;
printf("Enter first number = ");
scanf("%d", &a);
printf("Enter second number = ");
scanf("%d", &b);
sum = a + b;
printf("Sum of %d and %d is %d",a, b,sum);
return 0;
}
3
3. Program to Read the radius of a circle, calculate its area and display it
/* Read the radius of a circle, calculate its area and display it */
#include<stdio.h>
#define PI 3.141592
int main()
{
int radius;
float area;
printf("Radius of Circle = ");
scanf("%d", &radius);
area = radius*radius*PI;
printf("Area of Circle = %6.2f",area);
return 0;
}
4. Program to Evaluate the arithmetic expression ((a -b / c * d + e) * (f +g))
/* Evaluate the arithmetic expression ((a -b / c * d + e) * (f +g)) and display its
solution. Read the values of the variables from the user through console. */
#include<stdio.h>
int main()
{
float a, b, c, d, e, f, g, expr_value;
printf("Enter the numbers a, b, c, d, e, f, g: \n");
scanf("%f %f %f %f %f %f %f",&a,&b,&c,&d,&e,&f,&g);
expr_value = ((a -b / c * d + e) * (f + g));
printf("a=%0.2f,b=%0.2f,c=%0.2f,d=%0.2f,e=%0.2f,f=%0.2f,g=%0.2f \n", a, b, c, d,
e, f, g);
printf("Value of expression, y=((a-b/c*d+e)*(f+g))= %0.2f", expr_value);
return 0;
}
OUTPUT
1. Output of display “Hello World”
>>Hello World
4
2. Output of Read two numbers, add them and display their sum.
>>Enter first number = 84
>>Enter second number = 25
>>Sum of 84 and 25 is 109
3. Output of Read the radius of a circle, calculate its area and display it
>>Radius of Circle = 15
>>Area of Circle = 706.86
4. Output of Evaluate the arithmetic expression ((a -b / c * d + e) * (f +g))
>>Enter the numbers a, b, c, d, e, f, g: 2 3 5 8 6 4 5
>>a=2.00,b=3.00,c=5.00,d=8.00,e=6.00,f=4.00,g=5.00
>>Value of expression, y=((a-b/c*d+e)*(f+g))= 28.80
5
EXP. NO: 2
__/__/2024 LARGEST NUMBER AMONG 3 INTEGERS
AIM
To write a C program to Read 3 integer values and find the largest among them.
ALGORITHM
FLOWCHART
PROGRAM
/* Read 3 integer values and find the largest among them */
/* Using else if */
#include<stdio.h>
int main()
{
float n1, n2, n3;
printf("Enter three numbers:\n");
scanf("%f %f %f", &n1, &n2, &n3);
if( n1>n2 && n1>n3 )
printf("%0.2f is the largest number.", n1);
else if( n2>n3 )
printf("%0.2f is the largest number.", n2);
else
printf("%0.2f is the largest number.", n3);
return 0;
}
6
OUTPUT
>>Enter three numbers:
>>54 64 82
>>82.00 is the largest number.
7
EXP. NO: 3
__/__/2024 PRIME NUMBER
AIM
To write a C program to Read a Natural Number and check whether the number is prime
or not.
ALGORITHM
FLOWCHART
PROGRAM
OUTPUT
8
EXP. NO: 4
__/__/2024 ARMSTRONG NUMBER
AIM
To write a C program to Read a Natural Number and check whether the number is
Armstrong or not.
ALGORITHM
FLOWCHART
PROGRAM
OUTPUT
9
EXP. NO: 5 SUM AND AVERAGE OF AN ARRAY OF
__/__/2024 NUMBERS
AIM
To write a C program to Read n integers, store them in an array and find their sum
and average.
ALGORITHM
FLOWCHART
PROGRAM
OUTPUT
10
EXP. NO: 6
__/__/2024 LINEAR SEARCH
AIM
To write a C program to Read n integers, store them in an array and search for an element
in the array using an algorithm for Linear Search
ALGORITHM
FLOWCHART
PROGRAM
OUTPUT
11
EXP. NO: 7
__/__/2024 BUBBLE SORTING
AIM
To write a C program to Read n integers, store them in an array and sort the elements
in the array using Bubble Sort algorithm
ALGORITHM
FLOWCHART
PROGRAM
OUTPUT
12
EXP. NO: 8
__/__/2024 PALINDROME
AIM
To write a C program to Read a string (word), store it in an array and check whether it
is a palindrome word or not.
PROGRAM
OUTPUT
13
EXP. NO: 9
__/__/2024 STRING OPERATIONS
AIM
1. To write a C program to Read two strings (each one ending with a $ symbol), store
them in arrays and concatenate them without using library functions.
2. To write a C program to Read a string (ending with a $ symbol), store it in an array
and count the number of vowels, consonants and spaces in it.
PROGRAM
OUTPUT
14
EXP. NO: 10
__/__/2024 EUCLIDEAN DISTANCE
AIM
To write a C program to Read two input each representing the distances between two
points in the Euclidean space, store these in structure variables and add the two distance
values.
PROGRAM
OUTPUT
15
EXP. NO: 11
__/__/2024 DATA MANIPULATION USING STRUCTURE
AIM
To write a C program to Using structure, read and print data of n employees (Name,
Employee Id and Salary)
PROGRAM
OUTPUT
16
EXP. NO: 12
__/__/2024 DATA MANIPULATION USING UNION
AIM
To write a C program to Declare a union containing 5 string variables (Name, House
Name, City Name, State and Pin code) each with a length of C_SIZE (user defined
constant). Then, read and display the address of a person using a variable of the union.
PROGRAM
OUTPUT
17
EXP. NO: 13
__/__/2024 FACTORIAL
AIM
To write a C program to Find the factorial of a given Natural Number n using recursive
and non-recursive functions
ALGORITHM
FLOWCHART
PROGRAM
OUTPUT
18
EXP. NO: 14 STRING REVERSAL USING USER DEFINED
__/__/2024 FUNCTION
AIM
To write a C program to Read a string (word), store it in an array and obtain its reverse
by using a user defined function.
PROGRAM
OUTPUT
19
EXP. NO: 15
__/__/2024 MATRIX
AIM
To write a menu driven C program for performing matrix addition, multiplication and
finding the transpose. Use functions to (i) read a matrix, (ii) find the sum of two matrices,
(iii) find the product of two matrices, (iv) find the transpose of a matrix and (v) display a
matrix.
PROGRAM
OUTPUT
20
EXP. NO: 16
__/__/2024 POINTERS
AIM
1. To write a C program to Do the following using pointers
i. add two numbers
ii. swap two numbers using a user defined function
2. To write a C program to Input and Print the elements of an array using pointers.
3. To write a C program to Compute sum of the elements stored in an array using
pointers and user defined function.
PROGRAM
OUTPUT
21
EXP. NO: 17
__/__/2024 FILE OPERATIONS
AIM
1. To write a C program to Create a file and perform the following
i. Write data to the file
ii. Read the data in a given file & display the file content on console
iii. append new data and display on console
2. To write a C program to Open a text input file and count number of characters, words
and lines in it; and store the results in an output file.
PROGRAM
OUTPUT