i got this question and started and got a bit stuck can u please help. it goes like this
the questions asks us to
Write a c-program to read 10 numbers from the keyboard and store the numbers in an array called numbers After storing the numbers in the array do the following:
a). find and print the sum and average of even and odd numbers in the array.
b). find and print the largest and smallest element in the array. Also print the indesxes of the largest and smallest element in the array.

The following is what i did?? Help please thank you

# include <stdio.h>
void main()
{
      int numbers[10],num_val;
      int count,sum_even,sum_odd;
      float average;
      printf("please enter numbers to be added\n");
      scanf("%d",&num_val[numbers]);
      for(count=0;count<10;count+=1)
      { 
           if(num_val[count]%2==0)
           sum_even=sum_even+num_val[count];
           printf("sum even is =%d",sum_even);
           else if(num_val[count]%2!=0)
           sum_odd=sum_odd+num_val[count];
           printf("sum_odd is =%d",sum_odd);
      }
// this is where i got stuck

help please

i am kinda confused with is i was wondering if i should have used count, plus my obective is to add the elements entered

Write a c-program to read 10 numbers from the keyboard and store the numbers in an array called numbers After storing the numbers in the array do the following:

You're in the wrong forum. This the C++ forum, not the C-forum.

void main()

int main() is standard. Use that.

You declared numbers[10] to be an array and num_val as an integer, and then started using num_val as an array ??
I guess you should write the prog again from scratch coz you have got it all wrong here.

Declare an array numbers[10], Use scanf inside a for loop to get 10 numbers entered by the user. Then use two int variables sum_even and sum_odd to get the sum of even and odd numbers.

maybe some misunderstanding on your part ?

Nope, this thread got moved from C++ forum to C

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