Re: Need Help With The Array
[ Moved thread ]
// Please use CODE tags to make code more readable.
Re: Need Help With The Array
ok sorry boss
next time am gonna use it
Re: Need Help With The Array
Quote:
Originally Posted by
jacksparrow
ok sorry boss
next time am gonna use it
You can edit the previous post as well.
Re: Need Help With The Array
i edit the code ,,, why no one try to help me out in the answer... i thought it gonna be easy for the professionals
Re: Need Help With The Array
Quote:
Originally Posted by
jacksparrow
i edit the code ,,, why no one try to help me out in the answer... i thought it gonna be easy for the professionals
Now go back and use proper indentation and line up the braces. Once you do that, your biggest initial problem should be obvious.
Also, to get help, you need to be more specific than just saying it doesn't work. If there are compiler errors list them and tell us what line of code they're on.
Re: Need Help With The Array
Quote:
Originally Posted by
jacksparrow
i edit the code ,,, why no one try to help me out in the answer... i thought it gonna be easy for the professionals
Nothing is easy, don't ever take things for granted.
Next, properly indent the code as it still is a bit messy to read.
Third, when you compile this code, what's the first error message you see?
Fourth and the biggest mystery is, where is your array??
Re: Need Help With The Array
Quote:
Originally Posted by
potatoCode
Nothing is easy, don't ever take things for granted.
Next, properly indent the code as it still is a bit messy to read.
Third, when you compile this code, what's the first error message you see?
Fourth and the biggest mystery is, where is your array??
hello mate,, whats uP ?
ok lets to about the array
i should put it after using namespace right
# include <iostream>
using namespace std;
int arr = 10;
void insertzeros( int arr [],int & length ,int pos , int NB, const int SIZE)
Re: Need Help With The Array
That's a single int. There's no array.
There is a function parameter specified to be an array with the same name, but it's an unrelated variable.
Re: Need Help With The Array
That is a very strange assignment. What is length vs. SIZE? Does he want you to grow the array? What if the number of zeroes to insert plus the starting position puts you beyond the length or max size? I'd guess that length is the current amount of data that has been assigned and that SIZE is the actual size of the array, arr. Is that correct?
Re: Need Help With The Array
yeah it's really missed up assignment i have been given from my doctor , and i still couldnt answer it well.. anyway ur right he want me to put zeros in the start of pos and if there is no space in the length i have to make space and put zeros
Re: Need Help With The Array
i edited now the function and i think its correct , all i need to do now cout and cin
PHP Code:
void insertzeros (int arr[],int &length,int pos,int NB,const int SIZE)
{
if (length==SIZE)
{
cout<<"Sorry array is fall"<<endl;
return;
}
for(int j=0;j<NB;j++)
{
for (int i=length;i>=pos;i--)
{
arr[i]=arr[i-1];
}
arr[i]=0;
length++;
}
Re: Need Help With The Array
Quote:
Originally Posted by
jacksparrow
i edited now the function and i think its correct , all i need to do now cout and cin
PHP Code:
void insertzeros (int arr[],int &length,int pos,int NB,const int SIZE)
{
if (length==SIZE)
{
cout<<"Sorry array is fall"<<endl;
return;
}
for(int j=0;j<NB;j++)
{
for (int i=length;i>=pos;i--)
{
arr[i]=arr[i-1];
}
arr[i]=0;
length++;
}
Okaaaaaay. :confused:
Well good luck with your program. I'm not sure what you are asking for at this point.