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;
}

Recommended Answers

All 8 Replies

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

Your loop variable is fine, your formatting is just really inconsistent.

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

int main()
{
  cout <<"Enter 10 digits";
 int *a;
 a[]= new int [10];

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

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

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.