I am trying to write a C program that will first fill an array with upto 20 integers and then finds both the subscript of the largest item and the value of the largest item.
I am getting a couple of errors that I do not quit understand. I am using netbeans and cygwin as my compiler.
Here is the code I have so far.
CODE
#include <stdio.h>
#include <math.h>
#define item 20
int
main(void)
{
int arr[item];
int i;
int cur_large;
int large_sub;
printf ("Enter %d numbers separated by blanks or <return>s\n", item);
for (i = 0; i < item; ++1)
scanf("%d", arr[i]);
cur_large = arr[0];
for (i = 0; i < arr[item]; ++i)
if (arr[i] > cur_large)
cur_large = arr(i);
return(cur_large);
large_sub = 0;
for (i = 0; i < arr[item]; ++i)
if (arr[i] < arr[large_sub])
large_sub = i;
return(large_sub);
return(0);
}
Here is what the debugger tells me
CODE
Running "C:\cygwin\bin\make.exe -f Makefile CONF=Debug" in E:\Course Technology\CS 263\Assignment_4_1
/usr/bin/make -f nbproject/Makefile-Debug.mk SUBPROJECTS= .build-conf
make[1]: Entering directory `/cygdrive/e/Course Technology/CS 263/Assignment_4_1'
mkdir -p build/Debug/Cygwin-Windows
gcc.exe -c -g -o build/Debug/Cygwin-Windows/Arr.o Arr.c
Arr.c: In function `main':
Arr.c:16: error: invalid lvalue in increment
Arr.c:22: error: called object is not a function
make[1]: *** [build/Debug/Cygwin-Windows/Arr.o] Error 1
make[1]: Leaving directory `/cygdrive/e/Course Technology/CS 263/Assignment_4_1'
make: *** [.build-impl] Error 2
Build failed. Exit value 2.
any help or advice would be appreciated.