C 프로그램은 5개의 숫자에 대한 제곱근을 계산합니다. count 변수는 읽은 숫자의 개수를 저장합니다. count가 5보다 작거나 같으면 goto read 문은 제어를 레이블 읽기로 지시합니다. 그렇지 않으면 프로그램이 메시지를 인쇄하고 중지합니다.
Goto 문
프로그램의 다른 부분으로 제어를 전달하여 정상적인 프로그램 실행 순서 후에 사용됩니다.

프로그램
다음은 goto 문 사용을 위한 C 프로그램입니다 -
#include <math.h>
main(){
double x, y;
int count;
count = 1;
printf("Enter FIVE real values in a LINE \n");
read:
scanf("%lf", &x);
printf("\n");
if (x < 0)
printf("Value - %d is negative\n",count);
else{
y = sqrt(x);
printf("%lf\t %lf\n", x, y);
}
count = count + 1;
if (count <= 5)
goto read;
printf("\nEnd of computation");
} 출력
위의 프로그램이 실행되면 다음과 같은 결과가 생성됩니다 -
Enter FIVE real values in a LINE 2.3 -4.5 2 6.8 -44.7 2.300000 1.516575 Value - 2 is negative 2.000000 1.414214 6.800000 2.607681 Value - 5 is negative End of computation계산 종료