how to get out of function in c 1

how to get out of function in c

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!");
}

Here is what the above code is Doing:
1. It's creating a function called limit.
2. It's creating a variable called x and setting it to 0.
3. It's creating a loop that will run until x is greater than 100.
4. It's printing the value of x.
5. It's checking to see if x is equal to the value of stop.
6. If x is equal to stop, it prints "You won!" and returns.
7. If x is not equal to stop, it prints "I won!" and returns.

Similar Posts