explain method of validation in c8e7
This commit is contained in:
parent
397409d0ad
commit
2d6791220f
4
C8/ex7.c
4
C8/ex7.c
@ -7,7 +7,7 @@ int main() {
|
|||||||
|
|
||||||
printf("Enter radius: ");
|
printf("Enter radius: ");
|
||||||
rc = scanf("%f", &radius);
|
rc = scanf("%f", &radius);
|
||||||
// scanf returns number of scanned items
|
// scanf returns number of scanned items. If input is invalid then 0 values will have been scanned.
|
||||||
if (rc != 1) {
|
if (rc != 1) {
|
||||||
printf("Please enter an positive real integer or decimal\n");
|
printf("Please enter an positive real integer or decimal\n");
|
||||||
return 1;
|
return 1;
|
||||||
@ -15,7 +15,7 @@ int main() {
|
|||||||
|
|
||||||
printf("Enter height: ");
|
printf("Enter height: ");
|
||||||
rc = scanf("%f", &height);
|
rc = scanf("%f", &height);
|
||||||
// scanf returns number of scanned items
|
// scanf returns number of scanned items. If input is invalid then 0 values will have been scanned.
|
||||||
if (rc != 1) {
|
if (rc != 1) {
|
||||||
printf("Please enter an positive real integer or decimal\n");
|
printf("Please enter an positive real integer or decimal\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
Reference in New Issue
Block a user