Assignment 5
Assignment 5
Assignment 5
2. Write a program to find the sum of array elements using the function
Input
Input array elements: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
Output
Sum of array: 55
3. Write a function takes a matrix then return the sum of main diagonal (major
diagonal) elements of the matrix.
Input :
123
456
789
Output: 15
4. Write a function takes string then return the most repeated char
Input aaabca
Output: a
11. Write a function that takes an array of integers with size 10 and return an
array with EVEN numbers only.
Input: { 4,7,3,9,2,13,6,7,8,11}
Output: { 4,2,6,8}
12. Write a function to swap two numbers Using Pointer and display in main function
the values before and after swapping,
13. Write a program to dynamically allocate memory for an integer array, read values
from the user, and print them.
Input: 1 9 2 1 5
Output: 1 9 2 1 5
a) 12 b) 14 c) 13 d) Error
15. What will happen in this code? (Don’t USE Visual Studio or Codeblocks)
int a = 100, b = 200;
int *p = &a, *q = &b;
p = q;
a) b is assigned to a
b) p now points to b
c) a is assigned to b
d) q now points to a
Bounce:
1. Write a C++ program to change every letter in a given string with the letter
following it in the alphabet (i.e., a becomes b, p becomes q, z becomes a).
Example:
Input: w3resource
Output: x3sftpvsdf
2. Write a C++ program to capitalize the first letter of each word in a given string.
Words must be separated by only one space.
Example:
Sample Input: cpp string exercises
Sample Output: Cpp String Exercises
3. Complete the function/method so that it returns the url with anything after the
anchor (#) removed.
Examples
Input: www.code.com#about
Output www.code.com
Input: www.code.com?page=1
Output: www.code.com?page=1