You are on page 1of 16

EXPERIMENT NO 10

AIM

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.

ALOGRITHM

STEP_1 – start

STEP_2 – Define a structure named point with two integer members x,y and also
declare

Three variables p1,p2,p3

STEP_3 – In main function ....read the first point and store it in p1.

STEP_4 – Read the second point and store it in p2.

STEP_5—Add the corresponding coordinates of two points and store it in p3.

STEP_6 – Display the point p3

STEP_7 -- Stop

PROGRAM
OUTPUT
RESULT
THE PROGRAM HAS BEEN EXECUTED SUCCESSFULLY AND THE OUTPUT IS VERIFIED

EXPERIMENT NO 11

AIM

Using structure, read and print data of n employees (Name, Employee Id and
Salary)

ALGORITHM

STEP_1 – Start

STEP_2-- Employee with two integer variables to hold the employee


Initialize a structure id and salary and
a character variable to store the employee name as the structure
elements
STEP_3 -- Initialize an array of the datatype Employee to store the
details of the employees
STEP_4-- Input the number of employees from the user and using loops
obtain the employee details from the user
STEP_5 -- Print the details of the employees
STEP_6 -- Stop

PROGRAM
OUTPUT
RESULT
THE PROGRAM HAS BEEN EXECUTED SUCCESSFULLY AND THE OUTPUT IS VERIFIED

EXPERIMENT N0 12

AIM

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.

ALGORITHM
STEP_1—Start

STEP_2-- Initialize a union Address with character variables to store the


details of the address
STEP_3 -- Initialize a union of the datatype Address to store the address
STEP_4 --put the details of the address from the user
STEP_5 -- Print the details of the address.
STEP_6 -- Stop

PROGRAM
OUTPUT

EXPERIMENT NO 13

AIM

Find the factorial of a given Natural Number n usingrecursive and non recursive
functions

ALGORITHM

STEP_1--Start
STEP_2--Define functions factnr and factr to calculate the factorials
using the non-recursive and recursive functions respectively
STEP_3--Input the number whose factorial is to be calculated from the
user
STEP_4--Using the functions, calculate and print the factorials
STEP_5--Stop

PROGRAM

OUTPUT
RESULT
THE PROGRAM HAS BEEN EXECUTED SUCCESSFULLY AND THE OUTPUT IS VERIFIED

EXPERIMNT NO 1 4

AIM

Read a string (word), store it in an array and obtain its reverse by using a user
defined function.

ALGORITHM

STEP_1—Start

STEP_2--Define the function reversestr to take a string and reverse it


using a loop
STEP_3--Input the string to be reversed from the user and pass it on to
the function
STEP_4--Print the reversed string
STEP_5--Stop

PROGRAM
OUTPUT
RESULT
THE PROGRAM HAS BEEN EXECUTED SUCCESSFULLY AND THE OUTPUT IS VERIFIED

EXPERIMENT N0 16

AIM

Do the following using pointers i) add two numbers ii) swap two numbers using a
user defined function.

ALGORITHM

1. Start

2. Define a function add that takes two interger pointers


3. Define a function swap that takes two integer pointers as inputs
and uses a temporary variable to swap them
4. Declare variables for the numbers to be swapped and added
5. Input the value of the numbers from the user
6. Use the function to add the number and display the sum
7. Use the function to swap the two numbers
8. Print the numbers after swapping
9. Stop

PROGRAM

OUTPUT
RESULT
THE PROGRAM HAS BEEN EXECUTED SUCCESSFULLY AND THE OUTPUT IS VERIFIED

EXPERIMENT N0 17

AIM

Input and Print the elements of an array using pointers.

ALGORITHM

STEP_1--Start
STEP_2--Initialize an array and obtain its size from the user
STEP_3--Initialize an integer pointer that points to the first element of
the array
STEP_4--Using a loop, input the values of the array and store them
using the pointer
STEP_5--Using another loop, print the values of the array using the
pointer
STEP_6--Stop

PROGRAM

OUTPUT
RESULT
THE PROGRAM HAS BEEN EXECUTED SUCCESSFULLY AND THE OUTPUT IS VERIFIED

You might also like