Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,108 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,713 people online right now. Registration is fast and FREE... Join Now!




I need help

 
Reply to this topicStart new topic

I need help, insertion in an array with a specific algorithm

e_engineer
3 Oct, 2007 - 02:03 AM
Post #1

New D.I.C Head
*

Joined: 3 Oct, 2007
Posts: 3


My Contributions
hi i am a student i just begine in programming with c++ according to the algorithm that the instructor give us it is

for insert an element in an array i.e i have already the array and i want to insert an element on it
the algorithm

CODE
1 copy a[ins....right-1] into a[ins+1....right]
2 copy val into a[ins]
3 terminate  


This post has been edited by e_engineer: 3 Oct, 2007 - 02:17 AM
User is offlineProfile CardPM
+Quote Post

jjhaag
RE: I Need Help
3 Oct, 2007 - 02:27 AM
Post #2

me editor am smartastic
Group Icon

Joined: 18 Sep, 2007
Posts: 1,789



Thanked: 2 times
Dream Kudos: 775
Expert In: C,C++

My Contributions
read the rules. you need to make an attempt to address the problem yourself, and provide the course code that you have come up with. we won't do your work for you.

and please don't double post. edit your previous post if there's something that needs changing.

-jjh

This post has been edited by jjhaag: 3 Oct, 2007 - 02:28 AM
User is offlineProfile CardPM
+Quote Post

e_engineer
RE: I Need Help
3 Oct, 2007 - 02:58 AM
Post #3

New D.I.C Head
*

Joined: 3 Oct, 2007
Posts: 3


My Contributions
sorry for doubling my post i don't know how to delete the other topic
about my attempt
CODE
  include<iostream.h>
int main()
{

int arr[4],val;
cout<<"enter the element of array";
for(int i=0;i<=3;i++)
{
cout<<"enter the"<<i+1<<"element: ";
cin>>arr[i]
}
for(int i=0;i<=3;i++)
{
for(j=1;j<=2;j++)
arr[i]=arr[j];
cout<<"insert the value u want:";
cin>>val;
arr[j]={val}
}
}


This post has been edited by e_engineer: 3 Oct, 2007 - 03:01 AM
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 09:21PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month