Devc++ returns "uncompiled source file". Why?

Asked

Viewed 12,458 times

1

I can compile the file quietly only when I run it presents the source file not compiled. Could anyone help me?

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

int main ()
{
    float a, b, c, y;
    printf("\nDigite os valores de a,b e c: ");
    scanf("%f %f %f", &a, &b, &c);
    while (a>b);
    if (b>c)
        y=(a+b*c);
    else
        y=(a+c*b);
    printf("o valor do Y e: ", y);
    while(a<b);
    if (a>c)
        y=(a+b*b);
    else
        y=(b+c*a);
    printf("o valor do Y e: ", y);
    system("PAUSE");
}
  • What is error message?

  • source file not compiled

  • 2

    Not the problem with your question, but this one: while (a>b); is an infinite loop and will crash your program when it opens.

  • 1

    Unrelated to the question, but your printfs don’t work, you have to add the formatting modifiers (see this reply). Also you lack a Return 0 at the end.

  • Thank you, now you’re going.

1 answer

3


Dev-C++ is an obsolete IDE and so I don’t recommend using it due to various project bugs that occur.

If you really like Dev-C++ I suggest you install wxDev-C++ because it is a software that is still being developed or Code::Blocks

As for your code there are several things that should be highlighted:

You don’t even need #include <stdlib.h> (although it used the system function that is present in it) it is worth noting that it is not a good practice to call system functions. And all you used the system was to wait after the program’s closure, for this kind of case, I suggest you just use one scanf().

The library #include <conio.h> is not called at any time in that code and I also do not recommend using it for portability reasons. I usually see them using the conium getch() . h for the same purpose that used the SYSTEM("PAUSE") and both are mostly unnecessary because the stdio scanf. h achieves the same effect and you are already using the same.

while (a>b); this while has everything to go wrong, you run a loop without, making no interaction. Even if one of the items in this loop was y (which you change later) this loop would still be infinite because after the while condition you use the ;. To place elements inside a loop you need to use the keys { }.

printf will not display the variable unless you specify where it should be shown in string formatting.

Below I leave an example of what I believe I was looking to do with this code:

#include <stdio.h>

int main ()
{
    float a, b, c, y;
    printf("\nDigite os valores de a,b e c: ");
    scanf("%f %f %f", &a, &b, &c);
    while (a>y){
        if (b>c)
            y=(a+b*c);
        else
            y=(a+c*b);
        printf("o valor do Y e: %f", y);
    }

    while(y<b){
        if (a>c)
            y=(a+b*b);
        else
            y=(b+c*a);
    }
    printf("o valor do Y e: %f", y);
    scanf("",&a);
    return 0; // return EXIT_SUCCESS;
}

Browser other questions tagged

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