#include <fstream>
#include <iostream>
#include <iomanip>



int main()
{
    int index;
    int counter=0;
    double comparison_variable;

    float numbers;
    double array_numbers[10]; // an array with 10 floating points


  for(index=0; index < 10; index++)  
    {
          cout <<"enter array_numbers"<< (index +1)<<":" ; ERROR: undeclared (first use this function          

                 cin >>array_numbers[index];

                  if(index > 0)
{
                  if(numbers(index)> numbers(0))
{

         counter = counter +1
}

}}         cout <<"counter =" << counter <<endl;

system("PAUSE");
return 0;
}

Recommended Answers

All 5 Replies

You're not using anything to describe where the functions are coming from. You have included files, but the function references are ignored because (in this case) they are not preceded by a "std::" As your code stands, you will need to add std:: before most of your functions. E.g. std::cout<< "Text..." OR you can add using namespace std; to your code like shown below:

#include <iostream>

using namespace std;

int main()
{
   // Code
   return 0;
}

Regards,
Dennis M.

So why don't you comply with all those valuable piece of advice you have got in your 2-day-old former thread?

If you had only compared above program with that one posted in your former thread, you would have already spotted the principal mistake. Then you were ready to figure out some logic mistake too.

Ah, Dennis already hint at it.


-- tesu

I am now getting another error: _numbers' cannot be used as a function
#include <fstream>
#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
int index;
int counter=0;
double comparison_variable;

float numbers;
double array_numbers[10]; // an array with 10 floating points


for(index=0; index < 10; index++)
{
cout <<"enter array_numbers"<< (index +1)<<":" ;
cin >>array_numbers[index];

if(index > 0)
{
if(numbers(index)> numbers(0)) ERROR numbers' cannot be used as a function
{

counter = counter +1
}

}} cout <<"counter =" << counter <<endl;

system("PAUSE");
return 0;
}

How do you access the elements of an array? Hint you did it just fine about 4 lines before that.

It's not critical but usually the notation counter++ is used instead of counter = counter + 1 Also Please use code tags [code] //code goes here [/code]

float numbers;
|
?
|
V
numbers(index)> numbers(0) ??

Do you mean:  

array_numbers[index]  ?

Of course, USE CODE TAGS !

-- tesu

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.