Advertisement

Assignment No. 02 Semester: FALL 2009 CS201: Introduction to Programming

Instructions

Please read the following instructions carefully before submitting assignment:

It should be clear that your assignment will not get any credit if:

§ The assignment is submitted after due date.

§ The submitted assignment does not open or file is corrupt.

§ All types of plagiarism are strictly prohibited.

Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted. If you will submit code in .doc (Word document) you will get zero marks.

Objective

The objective of this assignment is to provide hands on experience of using

§ Basic concepts of C++ language and Programming

§ Conditional statements of C language

§ Arrays in c language

§ Char manipulation in c++

§ Sorting in c++

§ Merging arrays

Guidelines

§ Code should be properly aligned and well commented.

§ Follow c/c++ rules while writing variables names, function names etc

§ Use only dev-C++ for this assignment.

§ Use appropriate c/c++ structure i.e. loop, if-else, switch statement etc to get inputs from user (Marks will be deducted if inappropriate structure will be used).

Assignment

Problem Statement: Merging and Sorting of character arrays

You are required to write a program that takes character values in two different arrays as input from user. After getting input, make a third array and merge both these array in third array. Output array must be sorted in ascending order.

Detailed Description:

1. Declare three character type arrays.

2. Use two arrays to take input from user.

o Take input as char type.

o Take 10 values in each array.

3. Merge both these input arrays.

o If an input character is in both arrays, then it should appear once in resulted array.

4. Store result in third array.

5. Sort resulted array in ascending order.

o Ascending order means string values starting from ‘a’ will come first, and then starting from ‘b’ and so on.

6. Display them after sorting

Sample Output

Enter values in first array: a h b c u v I j k e

Enter values in Second array: y u d f g k I w q a

Merged array: a y h u b d c f g v k I j w q e

Sorted Array in ascending order: a b c d e f g h I j k q u v w y

Deadline

Your assignment must be uploaded/submitted on or before November 16, 2009

0 Responses