Return EXIT_SUCCESS


#1

I tried using [color=#004000]return EXIT_SUCCESS[/color] in the following C program, but the compiler is giving error: [color=#FF0000]Use of undeclared identifier ‘EXIT_SUCCESS’[/color]. What needs to be done to use this return method?

[code]#include <stdio.h>

float remainingAngle(float angleA, float angleB)
{
float angleC = 180 - angleA - angleB;
return angleC;
}

int main(int argc, const char * argv[])
{
float angleA = 30.0;
float angleB = 60.0;
float angleC = remainingAngle(angleA, angleB);

printf("The third angle is %.2f\n", angleC);
return EXIT_SUCCESS;

}[/code]


#2

Oh, sorry. I realized I needed to include the stdlib.h library. Then it works fine.

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