This browser does not support JavaScript. In order to use this test, please update your browser to a JavaScript compatible browser, or choose the CGI version of this test. Internet Explorer browsers are updated by http://www.microsoft.com/ie/, and Netscape browsers updated by accessing http://www.netscape.com/
1. The statement that tests to see if sum is equal to 10 and total is less than 20, and if so, prints the text string "incorrect.", is
if( (sum = 10) && (total < 20) ) printf("incorrect.");
if( (sum == 10) && (total < 20) ) printf("incorrect.");
if( (sum == 10) || (total < 20) ) printf("incorrect.");
2. if flag is 1 or letter is not an 'X', then assign the value 0 to exit_flag, else set exit_flag to 1.
if( (flag = 1) || (letter != 'X') ) exit_flag = 0; else exit_flag = 1;
if( (flag == 1) || (letter <> 'X') ) exit_flag = 0; else exit_flag = 1;
if( (flag == 1) || (letter != 'X') ) exit_flag = 0; else exit_flag = 1;
3. rewrite the following statements using a switch statement
if( letter == 'X' ) sum = 0; else if ( letter == 'Z' ) valid_flag = 1; else if( letter == 'A' ) sum = 1; else printf("Unknown letter -->%c\n", letter );
switch( letter ) { case 'X' : sum = 0; break; case 'Z' : valid_flag = 1; break; case 'A' : sum = 1; break; default : printf( "Unknown letter -->%c\n", letter ); break; }
switch( letter ) { case 'X' : sum = 0; case 'Z' : valid_flag = 1; case 'A' : sum = 1; default : printf( "Unknown letter -->%c\n", letter ); }
switch( letter ) { case "X" : sum = 0; break; case "Z" : valid_flag = 1; break; case "A" : sum = 1; break; default : printf( "Unknown letter -->%c\n", letter ); break; }
©Copyright B Brown. 1984-1999. All rights reserved.