C++ examples for Statement:if
Program that ensures age values are reasonable with if statement
#include <stdio.h> int main()/*from www . ja v a 2s . c o m*/ { int age; printf("\nWhat is the student's age? "); scanf(" %d", &age); // With scanf(), remember the & if (age < 10) { printf("%c", '\x07'); // BEEP printf("*** The age cannot be less than 10 ***\n"); printf("Try again...\n\n"); printf("What is the student's age? "); scanf(" %d", &age); } printf("Thank you. You entered a valid age."); return 0; }