Assignment No. 03 Semester: Spring 2009 CS201: Introduction toProgramming Total
ID: 3611662 • Letter: A
Question
Assignment No. 03
Semester: Spring 2009
CS201: Introduction toProgramming
Total Marks: 20
Due Date:29/05/2009
Instructions
Please read the following instructions carefully beforesubmitting assignment:
It should be clear that your assignment will not get anycredit if:
§ The assignment is submitted after due date.
§ The submitted assignment does not open or file iscorrupt.
§ All types of plagiarism are strictlyprohibited.
Note: You have to upload only.cpp file. Assignment in any other format(extension) will not be accepted. If you will submit codein .doc (Word document) you will get zero marks.
Objective
The objective of this assignment is to provide hands onexperience of using
§ MemoryAllocation in C/C++
§ Array inC/C++
Guidelines:
§ Codeshould be properly aligned and well commented.
§ Followc/c++ rules while writing variables names, function names etc
§ Use onlydev-C++ for this assignment.
Assignment
Problem Statement:
Dynamic memory allocation/reallocation of an Integer array.
Detailed Description:
Write a program in which you have to:
1. Dynamically allocate an array of integers.
2. Take array size as input from user and allocate memoryaccording to this size.
3. Take values of array elements as an input from user.
4. Print all array values.
5. In this step; double the previous array size (taken instep 2) and reallocate memory for the array according to new arraysize. For example if user provided array size is 4; now it willbecome 8, i.e. allocate memory for array having size 8.
6. Now again take values for second half of the array as aninput from the user to fill the increased size of an array.(Youhave already taken the values of first half of the array elementsin step 3, now take values for remaining elements i.e. Secondhalf).
7. Print all values of the array.
8. Also confirm that first half values ofarray are same in both printout statements (step 3 and step 7).
Sample Output
Program to dynamically Allocates an array of integers.
Enter the size of the array: 4
Enter a value: 1
Enter a value: 2
Enter a value: 3
Enter a value: 4
The elements of the array are:
1 2 3 4
Enter the elements in the array after reallocation:
Enter a value: 5
Enter a value: 6
Enter a value: 7
Enter a value: 8
1 2 3 4 5 6 78
Deadline
Your assignment must be uploaded/submitted on orbefore 29-05-2009.
Assignment No. 03
Semester: Spring 2009
CS201: Introduction toProgramming
Total Marks: 20
Due Date:29/05/2009
Instructions
Please read the following instructions carefully beforesubmitting assignment:
It should be clear that your assignment will not get anycredit if:
§ The assignment is submitted after due date.
§ The submitted assignment does not open or file iscorrupt.
§ All types of plagiarism are strictlyprohibited.
Note: You have to upload only.cpp file. Assignment in any other format(extension) will not be accepted. If you will submit codein .doc (Word document) you will get zero marks.
Objective
The objective of this assignment is to provide hands onexperience of using
§ MemoryAllocation in C/C++
§ Array inC/C++
Guidelines:
§ Codeshould be properly aligned and well commented.
§ Followc/c++ rules while writing variables names, function names etc
§ Use onlydev-C++ for this assignment.
Assignment
Problem Statement:
Dynamic memory allocation/reallocation of an Integer array.
Detailed Description:
Write a program in which you have to:
1. Dynamically allocate an array of integers.
2. Take array size as input from user and allocate memoryaccording to this size.
3. Take values of array elements as an input from user.
4. Print all array values.
5. In this step; double the previous array size (taken instep 2) and reallocate memory for the array according to new arraysize. For example if user provided array size is 4; now it willbecome 8, i.e. allocate memory for array having size 8.
6. Now again take values for second half of the array as aninput from the user to fill the increased size of an array.(Youhave already taken the values of first half of the array elementsin step 3, now take values for remaining elements i.e. Secondhalf).
7. Print all values of the array.
8. Also confirm that first half values ofarray are same in both printout statements (step 3 and step 7).
Sample Output
Program to dynamically Allocates an array of integers.
Enter the size of the array: 4
Enter a value: 1
Enter a value: 2
Enter a value: 3
Enter a value: 4
The elements of the array are:
1 2 3 4
Enter the elements in the array after reallocation:
Enter a value: 5
Enter a value: 6
Enter a value: 7
Enter a value: 8
1 2 3 4 5 6 78
Deadline
Your assignment must be uploaded/submitted on orbefore 29-05-2009.
Explanation / Answer
Assignment No. 03 Semester: Spring 2009 CS201: Introduction toProgramming Total
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.