Computer Science, asked by binu61401, 10 months ago

A C program in ends with a​

Answers

Answered by GurleenDhillon025
0

Answer:

In C programming, the return keyword can blast out of a function at any time, sending execution back to the statement that called the function. Or, in the case of the main() function, return exits the program. That rule holds fast even when return doesn’t pass back a value, which is true for any void function you create. Consider Exiting a Function with return.

EXITING A FUNCTION WITH RETURN

#include <stdio.h>

void limit(int stop);

int main()

{

int s;

printf("Enter a stopping value (0-100): ");

scanf("%d",&s);

limit(s);

return(0);

}

void limit(int stop)

{

int x;

for(x=0;x<=100;x=x+1)

{

printf("%d ",x);

if(x==stop)

{

puts("You won!");

return;

}

}

puts("I won!");

}

The silly source code shown in Exiting a Function with return calls a function, limit(), with a specific value that’s read in Line 10. A loop in that function spews out numbers. If a match is made with the function’s argument, a return statement (refer to Line 25) bails out of the function.

Otherwise, execution continues and the function simply ends. No return function is required at the end of the function because no value is returned.

Similar questions