#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0

    Why am I geting error '>' expected?


    I don;t see any problems with this code. Please give me a hand!

    Code:
    #include <stdio.h> 
    
    
    int main(void) {
    	int numbers[2], result[2];
    		printf("Enter two numbers separated by a space:");
    		scanf("%d %d", &numbers[0], &numbers[1]);
    		result[0] = numbers[0] - numbers[1];
    		result[1] = numbers[0] + numbers[1];
    		printf("Numbers taken away: %d\n,Numbers added: %d" result[0], result[1];
    		return 0;
    		}
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    156
    Rep Power
    34
    You're missing a comma to separete the 1st and 2nd arguments to your last printf() call.

    The compiler could help you detect the error. My compiler says:

    test.c:10:57: error: expected `)` before `result`

    That makes me look attentively at line 10.
    Last edited by bdb; November 14th, 2012 at 10:27 AM.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0
    Originally Posted by bdb
    You're missing a comma to separete the 1st and 2nd arguments to your last printf() call.

    The compiler could help you detect the error. My compiler says:

    test.c:10:57: error: expected `)` before `result`

    That makes me look attentively at line 10.
    Does 57 refer to characters in the compiler?

    I don't understand though. There is a comma before 'result' and I just added a comma before the first one. The problem still persists!
    Code:
    printf("Numbers taken away: %d\n, Numbers added: %d", result[0], result[1];
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    156
    Rep Power
    34
    Now you're missing a ')' after the final parameter to the printf() call and before the semicolon.

    Also, try to terminate output with a newline. This is the standard convention for command-line utilities.
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2012
    Posts
    9
    Rep Power
    0
    Originally Posted by bdb
    Now you're missing a ')' after the final parameter to the printf() call and before the semicolon.

    Also, try to terminate output with a newline. This is the standard convention for command-line utilities.
    That's it. I was looking for one thing and could not find the other. Thanks for help!
  10. #6
  11. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,111
    Rep Power
    1803
    Originally Posted by the5thace
    Does 57 refer to characters in the compiler?
    Code:
    test.c:10:57: ...
    Refers to file test.c, line 10, column 57.

    Not all compilers provide a column number reference in reporting, so for very long expressions or argument lists it is often useful to split them over multiple lines.

    Your compiler may yield different messages; when posting a code fragment that fails to compile, do post the error messages.

IMN logo majestic logo threadwatch logo seochat tools logo