getting this error while running this simple c calculator: the error: "error: expected identifier or '(' before '{' token"

Viewed 22

the code that I have written is this but I'm getting this error i.e. error: expected identifier or '(' before '{' token

#include <stdio.h>
#include <stdlib.h>



 int main();
{
    int num1;
    int num2;

    printf("Enter  your first number: ");
    scanf("%d", &num1);
    printf("Enter your second number: ");
    scanf("%d", &num2);

    printf("Answer: %d", num1+num2);

    return 0;
}
1 Answers

This works:

#include <stdio.h>
#include <stdlib.h>



int main() /* I just took out the semicolon... */
{
  int num1;
  int num2;

  printf("Enter  your first number: ");
  scanf("%d", &num1);
  printf("Enter your second number: ");
  scanf("%d", &num2);

  printf("Answer: %d\n", num1+num2);

  return 0;
} 
Related