Discussion Locked

Programming C

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Can someone help me to get the c program below to run?
Thanks

//
// array2.c -- Read/writing/reversing integer arrays
//

#include

#define NMAX 10

void intSwap(int *x, int *y);
int getIntArray(int a[], int nmax, int sentenel);
void printIntArray(int a[], int n);
void reverseIntArray(int a[], int n);

int main(void)
int x[NMAX];
int hmny;

hmny = getIntArray(x, NMAX, 0);
printf("The array was: \n");
printIntArray(x,hmny);
reverseIntArray(x,hmny);
printf("after reverse it is:\n");
printIntArray(x,hmny);
}

void intSwap(int *x, int *y)
/* It swaps the content of x and y */
{
int temp = *x;
*x = *y;
*y = temp;
}

void printIntArray(int a[], int n)
/* n is the number of elements in the array a.
* These values are printed out, five per line. */
{
int n;

for (i=0; i

3 replies

by jeng

Here's what I can see...

int main(void)
Missing opening brace "{" for start of function main()

if (i%5=0)
Missing opening brace "{" in function printIntArray()
Illegal comparison - possibly mean if((i%5)==0)

if (temp==sentinel) breakMissing semicolon ";"

a[n+] = temp;
Possibly mean post-increment n - a[n++] = temp;

intSwap(&a[i],&a[n-i-2]);
Logic error: possibly mean a[n-i-1]

}
Extra closing brace at end-of-file.

This discussion is closed to new replies.