can someone solve this??

i was testing my knolage on c++
by making this code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
using namespace std;
int a,b,c,d=5,e,f,g,h,i;
int main(){
    cout<<"please enter a number two count down from:";
    cin>>a;
    cout<<"\n\nplease enter a number to stop on \notherwise type 0:";
    cin>>b;
    cout<<"\n\nplease enter a number to skip from:";
    cin>>e;
    cout<<"\n\nplease enter a number to skip to:";
    cin>>f;
    cout<<"\n=================================-\n";
    cout<<'\n\n';
    g=e-f;
    h=g;
    int  arra[g];
    do{
    arra[g]=e;
    --e;--g;
}while (g>0);
g=0;
 for (;0<a;--a){  
 do{   if (arra[h]==a) continue   ;
 --h;
    }while(h!=0);
    --h; 
    cout<<a<<',';

c=0;
if (a==b){c=5;
          cout<<"  Count down terminated\n\n\n";
break;}
}
if (c!=d)cout<<"\n BANG\n\n";
system ("pause");}

and i can't find were the bugg is its intended to
1st ask a number to count down from
2nd ask a number to stop at (if any)
3rd ask numbers to skip from and too

but i keep on getting an "arra size unknown" message can anyone help PLEASE
this is the most complex code i have writen so far.
It is line 17. ISO C++ doesn't allow that.

You can create a large array and just protect it from being accessed beyond its ends.

Or you can use operator new:
int* arra = new int[ g ];
and before system("pause") don't forget to
delete[] arra;

Line 14 has an error too. Change your ' s to " s.

Hope this helps.
Change the quotes on line 28, too.
It is not necessary to change the quotes in line 28...
The use of double quotes is for strings cout << "This is a string"; //Necessary double quotes
The use of single quotes is for chars cout << 'c'; //Not necessary double, single is fine
If you just want to use a char you can use single quotes. But to use multiple characters you have to use double quotes.
That's why line 14 is wrong, it has two characters (2 times the '\n') but line 28 is correct (only one char ',')
Last edited on
Oh, right, just noticed.

Oops.
thanks a million would never of quessed it thanks!!
Topic archived. No new replies allowed.