Can any one say why the break state does not work.

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

int main()
{
    int n;
    loop:
    scanf("%d",&n);
    if(n!=42){
    printf("%d",n);
    goto loop;}
   else
    {
    break;
    }
   
    return 0;
}

this is my code.

The error is .....
14 E:\codechef.cpp break statement not within loop or switch

You can only use break within a loop, or a switch. The C++ loops are for, while and do-while. You have no loop, so you cannot use break.