943,960 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 3172
  • C++ RSS
May 26th, 2009
0

Dynamic memory allocation/reallocation of an Integer array

Expand Post »
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 memory according 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 in step 2) and reallocate memory for the array according to new array size. For example if user provided array size is 4; now it will become 8, i.e. allocate memory for array having size 8.

6. Now again take values for second half of the array as an input from the user to fill the increased size of an array.(You have already taken the values of first half of the array elements in step 3, now take values for remaining elements i.e. Second half).
7. Print all values of the array.
8. Also confirm that first half values of array are same in both printout statements (step 3 and step 7).
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
saalvi is offline Offline
3 posts
since Dec 2008
May 26th, 2009
0

Re: Dynamic memory allocation/reallocation of an Integer array

Click to Expand / Collapse  Quote originally posted by saalvi ...
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 memory according 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 in step 2) and reallocate memory for the array according to new array size. For example if user provided array size is 4; now it will become 8, i.e. allocate memory for array having size 8.

6. Now again take values for second half of the array as an input from the user to fill the increased size of an array.(You have already taken the values of first half of the array elements in step 3, now take values for remaining elements i.e. Second half).
7. Print all values of the array.
8. Also confirm that first half values of array are same in both printout statements (step 3 and step 7).
So what do you suggest we do with it? We are not here to do your homework, just because you are too lazy to even attempt it. You have to show that you have at least made an effort to start your assignment and we can correct your code/ideas if they're wrong. We (at least, I) refuse to waste time doing other people's assignments for them. See the links below:


Announcement 2
- Regarding Homework Help.

How to ask questions the smart way.
Reputation Points: 130
Solved Threads: 22
Junior Poster
amrith92 is offline Offline
187 posts
since Jul 2008
May 26th, 2009
1

Re: Dynamic memory allocation/reallocation of an Integer array

...What about it? Do you have a question? If you haven't noticed, this is a website to answer concrete questions, not do your homework.

And this assignment is very easy! Look in other websites or read the bpook assigned, and compile the program you make, if there is something wrong, then you can ask here, CONCRETE QUESTIONS. Geesh, lazy person!
Reputation Points: 17
Solved Threads: 0
Newbie Poster
MariaERamos is offline Offline
10 posts
since May 2009
May 26th, 2009
0

Re: Dynamic memory allocation/reallocation of an Integer array

Click to Expand / Collapse  Quote originally posted by amrith92 ...
So what do you suggest we do with it? We are not here to do your homework, just because you are too lazy to even attempt it. You have to show that you have at least made an effort to start your assignment and we can correct your code/ideas if they're wrong. We (at least, I) refuse to waste time doing other people's assignments for them. See the links below:


Announcement 2
- Regarding Homework Help.

How to ask questions the smart way.
Wow, yeah, I agree with you! Infact, that assignment seems easy! The person must be too lazy to start it, I wonder where he/she got that this website was to do homework ... I might do it for practice.
Reputation Points: 17
Solved Threads: 0
Newbie Poster
MariaERamos is offline Offline
10 posts
since May 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Why This not working
Next Thread in C++ Forum Timeline: reading a text file in c++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC