You are on page 1of 1

Labsheet 9

Pointers
1. Program to find sum of 2 numbers.
2. Write separate function that swaps 2 numbers passed from main and prints
the swapped numbers from main.The return type of the function should be
void.
3. Write separate function that receives a string as argument and rearranges
the characters in the string in the alphabetical order.The function should
return void.Print the changed string in main.
4. Implement bubble sort using call by reference.
5. Implement selection sort using call by reference.
6. Write a program to find the size of a pointer.Also show pointer to any data
type occupies same space.
7. Find gcd and lcm of 2 numbers using 2 different functions.Perform the
operations using pointer concepts.
8. Write a program that receives a sorted array of integer.Then it will read an
integer value and insert that integer value in correct place(Use pointer to
array concept).
9. Perform matrix addition using array of pointers concept.
10.We have 2 arrays,A and B,each containing 10 integers.Write a function that
checks if every element of array A is equal to its corresponding element in
array B.The function must accept only 2 pointer values and return a
Boolean,true for equal and false for unequal.
11.Write a program that reads integers from the keyboard and places them in an
array.The program then will sort the array into ascending and descending
order and print the sorted lists.The program must not change the original
array or create any other integer arrays.
Hint:Requires 2 pointer arrays that are initially pointing to the integer
array.Rearrange the pointer arrays so that it points to data in ascending and
descending sequence respectively.
12.Declare an array of pointers to 3 functions.When the user enters a value
between 0 and 2,the value is used as the subscript into the array of pointers
to functions.The value is passed as argument to each function.Each function
prints its arguments value and its function name.
13.Create a function which reads a set of strings into an array.The function
should not have any arguments.The function should return the array and
print it in main function.
14.Write a program that reads a set of strings. A function should be called from
main with the array as argument.In the function definition,the argument
should be in the form of pointer to array and the function should sort the
strings and print them.

You might also like