"Program ended with exit code: 0"


#1

Hi! I did the challenge at the end of this chapter and after the usual printed line in the log (mine said “The sum of the two numbers is 45.139999.”), it then printed a line about the exit code being 0. I know this is a nitpicky little question, but since the previous examples in the book didn’t print this to the log, I am wondering why my program did. Here is my code:
(And thank you for your help, loving the book so far!)

#include <stdio.h>

int main (int argc, const char * argv[])
{

float first = 3.14;
float second = 42.0;
float sum;

sum = first + second;

printf("The sum of the two numbers is %f. \n", sum);

return 0;

}


#2

Truthfully, I don’t know.

You returned zero in both main functions. I would expect that the debugger would either always print the return code or never.

But, I wouldn’t worry about it too much. Just keep going.


#3

Hello, in my case I was always getting the final message 'Program ended with exit code: 0".
But with the program I made for the Chapter 3 Challenge, it is not giving me the message.

This is my code:

#include <stdio.h>

int main (int argc, const char * argv[])
{

    //Declaring the first floating point variable
    float Value1 = 3.14;
    printf("The first value is %f.\n", Value1);
    
    // Declaring the second floating point variable
    float Value2 = 42.0;
    printf("The second value is %f.\n", Value2);

    // Declaring the double variable to sum both values
    double Total;
    Total = Value1 + Value2;
    printf("The total value is %f.\n", Total);
    
    return 0;
}

And this is the output I receive:

[quote][Switching to process 2615 thread 0x0]
The first value is 3.140000.
The second value to use is 42.000000.
The total value is 45.139999.
Current language: auto; currently minimal
(gdb)[/quote]

And when trying to build and run again, it gives me the message:
Stop “2Floats”?
“2Floats” is already running. Click Stop to terminate and launch a new instance.


#4

I suspect that you accidentally added a breakpoint. (Explained later in the book) Is there a blue arrow in the gutter next to your code? That will make the program stop there so that you can inspect that values of your variables in the debugger.

Just drag the blue arrow away to delete it.