The syntax of the command is incorrect in c

I'm using gcc compiler for c programming.I'm trying to run "for loop" but in command prompt when I execute the program it gives "The syntax of the command is incorrect".

The program is:

#include <stdio.h>
int main()
{
 int x;
 for (x=1; x<=10; x++)
  {
   printf("%d\n",x);
  }
 return 0;
}

enter image description here

Upvotes: 0

Views: 208

Answers (1)

Dominique
Dominique

Reputation: 17493

Your computer does not understand that for is the name of your program because the shell has a builtin command named for. Give the executable another name, like for1, and it should work.

Upvotes: 1

Related Questions