1 / 4

# int age; 1-100 int score; 0-100 int month; 1-12 char sex; 'M' or 'F' - PowerPoint PPT Presentation

Range check 範圍檢查 :. int age; 1-100 int score; 0-100 int month; 1-12 char sex; 'M' or 'F' char house; 'L','M','C','S' char ans; 'y' or 'n'. /* 1a */ do{ printf ("Q: age(1-100)? "); scanf if(…) printf ("Error\n"); }while ( );. /* 1b */ do{ printf ("Q: age(1-100)? ");

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.

## PowerPoint Slideshow about ' int age; 1-100 int score; 0-100 int month; 1-12 char sex; 'M' or 'F'' - hadassah-noel

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

Range check 範圍檢查:

int age; 1-100

int score; 0-100

int month; 1-12

char sex; 'M' or 'F'

char house; 'L','M','C','S'

char ans; 'y' or 'n'

/* 1a */

do{

printf ("Q: age(1-100)? ");

scanf

if(…) printf ("Error\n");

}while ( );

do{

printf ("Q: age(1-100)? ");

scanf ("%d", &age);

}while ( ! );

if ( )

printf("Error\n");

/* 1c */

while (){

printf ("Q: age(1-100)? ");

scanf ("%d", &age);

if ( ! )

printf("Error\n");

}

do{

printf ("Q: are you hungry<y/n>? ");

scanf ("%c", &ans);

ans = (ans);

}while ( );

/* 2b */

do{

printf ("Q: are you hungry<y/n>? ");

scanf ("%c", &ans);

if (!(ansans ))

printf ("Error\n");

}while ( ! );

case 2:

case 4:

case 6:

case 9:

case 11:

default:

}

/* 3a */

do{

printf ("Q: month (1-12)? ");

scanf ("%d", &mm);

printf ("Q: day (1-31)? ");

scanf ("%d", &dd);

if(mm==) max = 28;

else if( )

max = 30;

else max = ___

if (!(mm>=1 && mm<=12 && dd>=1 && dd<= ))

printf ("Error - out of range!\n");

}while (mm || mm || dd || dd );