Docsity

Arrays-Characters and Array Programming-Assignment, Exercises of Computer Engineering and Programming

Toggle sidebar
bg1
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.
Docsity.com
pf2

Partial preview of the text

Download Arrays-Characters and Array Programming-Assignment and more Exercises Computer Engineering and Programming in PDF only on Docsity!

C O M P U T E R P R O G R A M M I N G ( C S 1 1 2 3 ) S P R I N G 2 0 1 2

A S 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.

Docsity.com

  1. Write a program that takes a character array of size 25 from user and prints the number of small letters, capital letters, numbers and special characters in the array. Hint: Use ASCII codes table provided in question 1.
  2. Write a program that takes a string of characters (in character array) from the user (assuming there are no white spaces entered) and then tells the user if the string entered is a palindrome or not. Take array size = 15.
  3. Write a program which will initialize a character array of size 10 from user input. Count the number of spaces in the array and display the result.

IMPORTANT INSTRUCTIONS:

  1. Read the problem carefully.
  2. For submission make a folder named your name and reg. no. for example amjad_bc013051 , paste all programs in it. File names of programs must be according to the question numbers.
  3. Submission date and time is fixed; it will not be extended in any case.
  4. Honest attempt of solving the assignment will be appreciated, therefore try to solve the assignment rather than copying it from your fellows.
  5. No compensation for copy cases and plagiarism. Strictly F grade will be awarded. - - - - - - - - - -GOOD LUCK - - - - - - - - - -

Docsity.com