
CO M P U T E R PR O G R A M M I NG ( C S 1 1 2 3 ) SP R I N G 2012
AS S I G N M E N T # 4
SUBMISSION DATE: 30-03-2012 SUBMISSION TIME: 6 PM
NOTE: Carefully read instructions given at the end of assignment before solving it.
1. Declare an integer array of size 20. Ask user to enter values in the array. Your task is to
swap the odd indexes with the even indexes (next to each odd index is the even index
which have to be swapped), you have to leave 0th index and 19th index as it is. After
swapping, display the swapped array.
2. Declare integer an array of size 10. Ask user to enter values in the array. Your task is to
display the number of distinct digits in the array. Example is given below:
Digit Count
4 3
2 5
10 2
3. Declare two integer arrays of sizes 14 each. Your task is to display the elements which are
common in both arrays.
4. Declare two integer arrays of sizes 8 each. Input values in arrays. Ask user to enter
choice. If user enters ā1ā, the program will display all those elements which are present
in the first array but they are not present in the second array. If choice is ā2ā, the
program will display all those elements which are present in the second array but they
are not present in the first array.
5. Declare an array A[ ] of size 6 and an array B[ ] of size 12. Your task is to determine
whether all the elements of A[ ] are present in B[ ] or not.
6. Write a program in which you have a character array of size 20. Input array from the
user. Ask the user to enter starting index and the numbers of characters. Then print the
array from the index given by the user considering the number of characters user wants
to print. Input can contain spaces.
7. Declare a character array of size of size 20. Input character array from user. Take a
character from the user and display the location(s) of that character in the array.
8. Declare a character array of size of size 20. Input the character array from the user.
Count the total number of characters stored in the array. Display the result.