0% found this document useful (0 votes)
27 views4 pages

Task 1:: Topic Objective

This lab focuses on implementing functions related to arrays. The tasks involve writing functions to: copy arrays; copy arrays in reverse order; merge two character arrays in alphabetical order; search for an element in an array; create a histogram from an integer array; find palindrome numbers in an array; calculate factorials; pass and display a 2D array; and sort an array in ascending and descending order.

Uploaded by

prince12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views4 pages

Task 1:: Topic Objective

This lab focuses on implementing functions related to arrays. The tasks involve writing functions to: copy arrays; copy arrays in reverse order; merge two character arrays in alphabetical order; search for an element in an array; create a histogram from an integer array; find palindrome numbers in an array; calculate factorials; pass and display a 2D array; and sort an array in ascending and descending order.

Uploaded by

prince12
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Lab 09

Topic Functions.
Learning objectives of this lab are to implement code related to
Objective
functions .

Task 1:
Write a function that takes two array called source and destination array. It copies source
array into destination array.
Task 2:
Write a function that takes two array called source and destination array. It copies source
array into destination array but in reverse order.
Task 3:
Write a function based program in which two character arrays are accepted from the
user.Your program then merges the two arrays in a third array but the entries are done in
alphabetical order.
Example:
Enter 1st array:
D R P I E A N

Enter 2nd array:


B G K Q M O L

Output:
A B D E G I K L M N O P Q R
Task 4:
Write a function based C++ program in which the user enters names of animals in a
character array of size 100. Then the user enters an animal’s name in second array and your
function determines if the second array is present in the first array.
Example:
Output:
Enter animals in character:
G O A T H O R S E R A B B I T S H E

Enter the animal to be found in character array: RABBIT


It is present in the array.

Task 5:
Write a function based C++ program that takes numbers in integer array of size ten from user.
Your program should graph this information in the form of bar chart or histogram – each
number is printed, than bar consisting of that many asterisks is printed besides number.
Output:
Enter numbers: 10 3 7 5 15 11 2 3 6 9
Element Value Histogram
0 10 **********
1 3 ***
2 7 *******
3 5 *****
4 15 ***************
5 11 ***********
6 2 **
7 3 ***
8 6 ******
9 9 *********
Task 6:
Write a function based C++ program that takes ten numbers into array from user and prints
all palindrome numbers in array.
Note: Assume numbers are always greater than 99.
Output:
Enter numbers: 101 223 435 3534 2323 3223 8888 978 4858 152
Palindrome numbers are: 101 3223 8888

Task 7:
Write a program to print the factorial of a number by defining a function named
'Factorial'.
Factorial of any number n is represented by n! and is equal to 1*2*3*....*(n-1)*n. E.g.-
4! = 1*2*3*4 = 24
3! = 3*2*1 = 6
2! = 2*1 = 2
Also,
1! = 1
0! = 0

Task 8:
Write a program to pass 2d array in function and display its value using functions.
Task 9:
Write a program in C to read an array containing n elements and sort this array in
ascending order and descending order using user defined function and display sorted
array from main function

You might also like