I have a program that prompts the user to input three float numbers and if those numbers are not positive or not digits it prints out "Invalid number"
This is the part of the program done with goto
loops and I'd like to get rid of it.
float array[n][3];
int i;
for(i = 0;i<n;i++){
one:
printf( "Please enter first number: ");
scanf("%f", &array[i][0]);
while(array[i][0]<0){
printf("Invalid number: ");
goto one;
}
two:
printf("Please enter second number: ");
scanf("%f", &array[i][1]);
while(array[i][1]<0){
printf("Invalid number: ");
goto two;
}
three:
printf("Please enter third number: ");
scanf("%f", &array[i][2]);
while(array[i][1]<0){
printf("Invalid number: ");
goto three;
}
}
How do I convert loops goto one
, goto two
and goto three
; in a while loop, or some kind of a loop?