54.9k views
0 votes
T F The exit function can only be called from main .

1 Answer

1 vote

Answer:

FALSE

Step-by-step explanation:

The exit function is used to terminate or halt the process.

Syntax-

void exit(int status)

Exit function (exit()) can be used in any function not only main() and it will terminate your whole process.

Example- C Program

#include<stdio.h>

#include <stdlib.h>

// function declaration

float exitexample ( float x );

// Driver program

int main( )

{

float a, b ;

printf ( "\\Enter some number for finding square \\");

scanf ( "%f", &a ) ;

// function call

b = exitexample ( a ) ;

printf ( "\\Square of the given number %f is %f",a,b );

/*This will not printed as exit function is in exitexample() function*/

}

float exitexample ( float x ) // function definition

{

exit(0); //exit function

float p ;

p = x * x ;

return ( p ) ;

}

User Reggie Carey
by
4.9k points