Hi,

I'm a beginner, please be gentle!

I have created a very simple program which reads in the dimensions of a rectangle then calculates area and volume.

The loop will terminate if a non-numerical integer is entered - is there a way of making it terminate if an integer which is equal to or less than 0 is entered? Ideally I'd like to make it so the loop will terminate if 0 or a negative number is entered at any of the three scanf() stages (enter length, enter width, enter height).

Here's my code:

Code:
#include <stdio.h>
int main(void)
{
    int length, width, height;
    
    printf("Enter the length of the rectangle: ");
    while (scanf("%d", &length) == 1)
    {
       printf("Length = %d:\n", length);
       printf("Enter the width: ");
       if (scanf("%d", &width) !=1)
          break;
       printf("Enter the height: ");
       if (scanf("%d", &height) !=1)
          break;    
       printf("The rectangle's area is %d and its volume is %d.\n", width * height, (length * width) * height);
       printf("Enter the length of the rectangle: ");
    }
    
    printf("Invalid - BYE.\n");

    getchar();
    getchar();
    getchar();
    return 0;
    
}
Any advice/guidance gratefully received

Cheers,

Twazzler