Question No. 1
Write a program that inputs a string from the user, calculates and displays its length.
(Note: you are not allowed to use any built in function)
Question No. 2
Write a program that inputs a string from the user and coverts all the capital letters to small letters and all the small letters to capital letters.
Example:
If the user enters string "HeLLo wOrLd", the program will display it as "hElllO WoRlD"
Question No. 3
Write a program which will take input from user in two integer arrays. The program should compare both arrays for checking if both arrays are totally identical (Exactly same). If not, then program should determine the matching indexes of both arrays. Matching indexes means that first element of array1 should be equal to first element of array2 and so on.
• If both arrays are exactly same, the program should display a message "Both arrays are identical".
• If both arrays are not exactly same, then program should match the indexes which have same elements in both arrays and display the matching indexes.
• If there is no element matching in both arrays, the program should display a message
"There is no matching element in both arrays".
Sample Output for two exactly same arrays
Please enter 10 integers for array1:
Enter element 1: 1
Enter element 2: 3
Enter element 3: 5
Enter element 4: 7
Enter element 5: 9
Enter element 6: 11
Enter element 7: 13
Enter element 8: 15
Enter element 9: 17
Enter element 10: 19
Please enter 10 integers for array2:
Enter element 1: 1
Enter element 2: 3
Enter element 3: 5
Enter element 4: 7
Enter element 5: 9
Enter element 6: 11
Enter element 7: 13
Enter element 8: 15
Enter element 9: 17
Enter element 10: 19
Both arrays are identical
Sample Output for arrays with some matching indexes
Please enter 10 integers for array1:
Enter element 1 : 1
Enter element 2 : 3
Enter element 3 : 5
Enter element 4 : 7
Enter element 5 : 9
Enter element 6 : 11
Enter element 7 : 13
Enter element 8 : 15
Enter element 9 : 17
Enter element 10 : 19
Please enter 10 integers for array2:
Enter element 1 : 2
Enter element 2 : 4
Enter element 3 : 5
Enter element 4 : 6
Enter element 5 : 9
Enter element 6 : 12
Enter element 7 : 14
Enter element 8 : 16
Enter element 9 : 17
Enter element 10 : 20
Both arrays have same elements on
Index 3
Index 5
Index 9
Question No. 4
Write a program that gets a string from the user and tells the number of vowels in that string. (Vowels are a, e, i, o, u)
Question No. 5
Declare two arrays of size 5. Get input from the user. Declare a third array of size 10. Put the values of array1 in even indexes of array3 and values of array2 in odd indexes of array3.
Example
Array1
1 2 3 4 5
Array2
6 7 8 9 10
Array3 will be
1 6 2 7 3 8 4 9 5 10
Question No. 6
Get two strings from user. Join first string with the second string with a space. Store in another string and display it.
Example:
Enter first string: Hello
Enter second string: World
Hello World
(Did not use build in function for string concatenation )
Question No. 7
Get a character from user and display its ASCII value. User will keep on entering the values and the ASCII values will keep on displaying until space bar is pressed.
Question No. 8
Get a string from user of maximum 80 characters and display the number of words and characters in that string. (total number of characters will also include spaces)
Example:
Enter String: This is my first C++ Program
Number of words: 6
Number of characters: 28
Question No. 9
Write a program that gets a string from user and copy that string to another empty string.
Question No. 10
Write a program that inputs a string from the user. Then it will take a character as input and prints the string onwards from that character.
Example:
Enter String: Hello World
Enter Character: l
lo World