You are on page 1of 2

LIST OF PROGRAM USING FUNCTION

Write a program in C++ that calculates factorial of number using function.


Print table of numbers using function.
find out sum of following series using function
(I) 1+22+32+42+--------till n term (taking n as parameter and return sum of
the series)
(II) 1+33+53+73+--------till n term (taking n as parameter and return sum of
the series)
(III) 1+(1+2)+(1+2+3)+--------------- till n term (taking n as parameter and r
eturn sum of the series)
(IV) 1-U+ U2 /2!- U3 /3! +----------- till n term (taking n and U as functio
n parameter and return sum of the series)
(V) a+ ar2 +ar3 +----------- till n term (taking n,a and r as function par
ameter and return sum of the series)
(VI) 1X+X2 +X3 +----------- till n term (taking n and X as function paramete
r and return sum of the series)
Write a program in C++ using function that print following patterns(taking no of
line for patterns as input):
1 (b) A (c ) A
1 2 1 A B C A B
A
1 2 3 2 1 A B C D A B C B A
1 2 3 4 3 2 1 A B C D E AB C D C B A
(d) * (e) 1
* * 1 2 3
* * * 1 2 3 4
* * * * 1 2 3 4 5
5. Write a C+ program that invoke a function length () that return length o
f input string. The function length () take a character array as input.
6. Write a C+ program that invoke a function count ( ) that return no of wo
rds present in a line using function. The function count () take a character arr
ay as input.
7. Write a C+ program that invoke a function reverse ( ) that reverse a st
ring. The function reverse () take a character array as input.
8. Write a C+ program that invoke a function countvowel ( ) that count no o
f vowels in a line. The function countvowel () take a character array as input
.
9. Write a C+ program that invoke a function palindrome ( ) that return 1 i
f it is palindrome otherwise 0. The function palindrome () take a character arra
y as input.
10. Write a C+ program that invoke a function replace ( ) that replace every
space in a string with hyphen. The function replace () take a character array a
s input.
11. Write following program in C++ using function that take an array and its
size as input parameters.
(i) Return largest element in array.
(ii) Return smallest element in array.
(iii) Find a element in array and return 1 if its present otherwise return 0.(
take searching element and array as input parameter).
(iv) Add two matrix(Take two, 2-D array and their size as input parameter an
d print their sum)
Subtract two matrix(Take two, 2-D array and their size as input parameter and p
rint their difference
Multiply two matrix(Take two, 2-D array and their size as input parameter and p
rint their product)
Display Transpose of a matrix
Find row sum and column sum of a matrix.
Print diagonal sum of a input matrix.
Count no of occurrences of each character in a line. E.g.
If u enters a line â ARRAY DECLARATIONSâ that output is
A 4
R 3
Y 1
D 1
E 1
(XI) Input a string as parameter in function and print in following manner:if
input string is â MALAYSIAâ
OUTPUT SHOULD BE:
M MALAYSIA
MA MALAYSI
MAL MALAYS
MALA MALAY
MALAY MALA
MALAYS MAL
MALAYSI MA
MALAYSIA M

You might also like