Hiii I am trying to dis program but i gives me an error.....i donno wat 2 do in this forum....plzzz hep me

#include <iostream>
using namespace std;
int main()
{
  cout <<"Enter 10 digits";
  int a[]= new a[10];
  for( int i=0;i<10;i++)
  cin>> a[10];
 
  int small,big;
 
  for(int i=0;i<10;i++)
  {
  if (a[i]<10)
  small+=a[i];
  else
    big+=a[i];
    cout<<big;
    }
    cout<<"small"<<small;
    cout<<"big"<<big;

    int all;
  for (int i=0;i<10;i++);
  {
      all+=a[i];
  }
  cout<<"all numbers"<<all;
    return 0;
}

You need to change

int a[]= new a[10];

to this:

int* a = new int[10];

also, you have "i" as the counter variable in both the outer loop and inner loop, that is definitely going to cause problems.

Dave

i didnt get u ....talking abt the "i" can u pls help with that
.........atmc

please write me about your problem I cant shurely understand you would you wrie me plz? <<snip>>

Edited 6 Years Ago by Nick Evan: Removed email

Ah, there is a missing bracket:

for(int i=0;i<10;i++)
  {
  if (a[i]<10)
  small+=a[i];
  else
    big+=a[i];
    cout<<big;
    }

should be:

for(int i=0;i<10;i++)
  {
  if (a[i]<10)
  small+=a[i];
  else
{
    big+=a[i];
    cout<<big;
}
    }

That's why I thought it was a nested loop.

Dave

int all;
  for (int i=0;i<10;i++);
  {
      all+=a[i];
  }
  cout<<"all numbers"<<all;
    return 0;
}

............................error is here

Edited 6 Years Ago by Nick Evan: added code tags

Gah. Duh. You have a semicolon at the end of the for loop. Always the small things that I miss. Damn semicolons.

This article has been dead for over six months. Start a new discussion instead.