C conditionals

From wikinotes

if statement

  • expressions evaluate to 0 in order to be true
if ( num == 5 ) {
	printf( "number is 5" );

} else if ( num == 6 ){
	printf( "number is 6" );

} else {
	printf( "unknown number" );
}

switch

switch( myvar ){

	case "horse":
	case "HORSE":
		printf("animal is a horse");
		break;

	case "dog":
		printf("animal is dog");
		break;

	default:
		printf("unknown animal");
}