Code compilation

Asked

Viewed 72 times

2

Guys help me, I can’t compile this code: Until starts the command screen no more runs

#include <stdio.h>

int main()

{
  int x,y,z;
  int a=0;
  for (x=0;x<=1;x=x+1)
    for(y=x;y<=1;y=y+1)
     for(z=y;z<=2;z=z+1)
       a=a+1;
printf("%d",a);
}
  • 2

    compiled here, the result was 7, which error is giving?

  • How did you manage to compile? in my note was not. (Windows)

  • I just copied and pasted in Dev C++ and compiled with F11. It’s on Windows?

  • Which IDE you are using?

  • Can you explain what IDE is?

  • For example, I can’t even compile #include <stdio. h> int main() { int x; int soma=0; int k =1; while (k<=15) { scanf("%d", &x); soma = sum + x; k = k + 1; } } ;}

  • See working and more organized to facilitate reading: http://ideone.com/NrJirM. I’ll repeat so you don’t insist on material that teaches you to make bad codes. If you are making a mistake to compile, post it. Give details so we can help.

  • @user32333 About IDE I use Codeblocks, the above friend used Dev C++ , This name comes from the English IDE(Integrated Development Environment). In a rough translation it would be: Integrated Development Environment. The IDE has many features that help with program development, but, roughly speaking, they basically have a compiler and a graphical interface!!

  • What compiler you are using?

  • @user32333 Syntactically the code is correct. To know why it is not compiling, the information that the above friends requested is necessary. Which is your operating system? Which is your IDE? Which is your compiler? What is the error noted?

Show 5 more comments

2 answers

1

System pause is a DOS command of the c.E language used to use DOS commands. The "pause" command is for pausing the program and not letting it close quickly. And you can’t forget to add include stdlib. h to use it.

0

There are no syntax errors in the code. C code is legitimate, compiles, and executes. The code executes and writes an integer on the screen the number 7. Perhaps the problem lies in some peripheral details. You can try to display some blank lines before and after the number so that it becomes more clear on the screen:

#include <stdio.h>

int main()
{
        int x, y, z;
        int a = 0;
        for(x = 0; x <= 1; x = x + 1)
                for(y = x; y <= 1; y = y + 1)
                        for(z = y; z <= 2; z = z + 1)
                                a = a + 1;
printf("\n\n %d \n\n", a);
}

In some environments it may be interesting you add system("pause"); before closing the keys to main, so that the window of the prompt don’t close yourself:

#include <stdio.h>

int main()
{
        int x, y, z;
        int a = 0;
        for(x = 0; x <= 1; x = x + 1)
                for(y = x; y <= 1; y = y + 1)
                        for(z = y; z <= 2; z = z + 1)
                                a = a + 1;
printf("\n\n %d \n\n", a);
system("pause");
}

It is important to check that at the time you compile the code there is no execution window already open. If it exists it will close before compiling your code.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.