In this recipe, we will learn how to implement validation using assertion. The program will ask the user to enter the information of the passengers that are flying from one place to another. Using assertions, we can ensure that the number of passengers entered is a positive number. If the number of passengers entered is zero or a negative value, the program will abort.
Applying assertions for validation
How to do it...
Follow these steps to create a validation check using assertion. The recipe will not allow the program to run if the value of the number of passengers is zero or negative:
- The user is prompted to enter how many passengers are flying:
printf("How many passengers ? ");
scanf("%d",&noOfPassengers...