HELP!!

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include<iostream>
using namespace std;
int main(){


int N,icount,sum_odd,sum_even,max_half,min_half,odd_avrg;

cout<<"Enter how many number followed by the set of integers : "<<endl;
cin>>N;
int inp[N];
max_half = 0;
min_half = (N)*999;
sum_odd = 0;
sum_even = 0;
icount = 0;
for(int i=0; i<N; i++)

    cout<<" Enter input number "<<i+0<<" : "<<endl;
cin>>inp[N];

for (int i=0; i<N; i++)
{

    if(i<= (N/2))
    {
        max_half = max(max_half , inp[i]);
    }


  if (i>(N/2))
  {
    min_half = min(min_half,inp[i]);
  }


  if((inp[i]%2)==0)
  {
      sum_even = sum_even + inp[i];
  }


  if((inp[i]%2)!=0)
  {
      sum_odd = sum_odd + inp[i];
      icount++;
  }

cout<<"The maximum of the first half is:"<<max_half<<endl;
cout<<"The minimum of the second half is:"<<min_half<<endl;
cout<<"The sum of all even numbers is:"<<sum_even<<endl;
cout<<"The average of all odd numbers is:"<<odd_avrg<<endl;

return 0;


}





can anybody help me i try to build and run this program but it dosen't work
compile it and read the errors.
i try to do it but i don't know how to correct it
this was the error

|56|error: expected '}' at end of input|
where are u guys !!!
Add a closing } at the end and that error will go away.

Then you would (or atleast should) get an error for line 10: int inp[N];
C++ does not have variable length arrays.

Fix that, and then pay heed to the warning on line 51: 'odd_avrg' may be used uninitialized

Fix that too, and after that you can get started with the arduous task of testing and debugging the code.
If you started using a sensible indentation style, it would help you see more quickly where you might have errors in your braces and with the flow of control.
Topic archived. No new replies allowed.