0% found this document useful (0 votes)
20 views3 pages

C++ Programs Using Functions List

The document lists 11 programs that can be written in C++ using functions. The programs include calculating factorials, printing tables, finding sums of series, printing patterns, finding the length and number of words in a string, reversing a string, counting vowels, checking for palindromes, replacing spaces with hyphens, performing operations on arrays and matrices like finding maximum/minimum values, searching, adding, subtracting, multiplying, finding transposes, row/column sums, and diagonals sums. It also includes programs to count character occurrences in a string and print a string in staggered format.

Uploaded by

Kanchan Khurana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views3 pages

C++ Programs Using Functions List

The document lists 11 programs that can be written in C++ using functions. The programs include calculating factorials, printing tables, finding sums of series, printing patterns, finding the length and number of words in a string, reversing a string, counting vowels, checking for palindromes, replacing spaces with hyphens, performing operations on arrays and matrices like finding maximum/minimum values, searching, adding, subtracting, multiplying, finding transposes, row/column sums, and diagonals sums. It also includes programs to count character occurrences in a string and print a string in staggered format.

Uploaded by

Kanchan Khurana
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd

LIST OF PROGRAM USING FUNCTION

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


function.
2. Print table of numbers using function.
3. 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 return sum of the series)
(IV) 1-U+ U2 /2!- U3 /3! +----------- till n term (taking n and U as
function parameter and return sum of the series)
(V) a+ ar2 +ar3 +----------- till n term (taking n,a and r as
function parameter and return sum of the series)
(VI) 1X+X2 +X3 +----------- till n term (taking n and X as function
parameter and return sum of the series)
4. Write a program in C++ using function that print following
patterns(taking no of line for patterns as input):
(a) 1 (b) A (c ) A
121 ABC ABA
12321 A BCD ABCBA
1234321 A BCDE AB C D C B A
(d) * (e) 1
** 123
** * 1234
* * * * 12345
5. Write a C+ program that invoke a function length () that return length of
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
words present in a line using function. The function count () take a
character array as input.
7. Write a C+ program that invoke a function reverse ( ) that reverse a
string. The function reverse () take a character array as input.
8. Write a C+ program that invoke a function countvowel ( ) that count no
of 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
if it is palindrome otherwise 0. The function palindrome () take a
character array 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 as 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 and print their sum)
(V) Subtract two matrix(Take two, 2-D array and their size as input
parameter and print their difference
(VI) Multiply two matrix(Take two, 2-D array and their size as
input parameter and print their product)
(VII) Display Transpose of a matrix
(VIII) Find row sum and column sum of a matrix.
(IX) Print diagonal sum of a input matrix.
(X) 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