C Programming

Practise Exercise 6

Compound Relationals and switch

JavaScript compatible inter-active version of this test.

1. if sum is equal to 10 and total is less than 20, print the text string "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.

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 );

Answers


ęCopyright B Brown. 1984-1999. All rights reserved.