/* 3.6 calculates the maximum value among the three numbers. Similar to example 1.2 */
# Include <stdio. h>
Void main ()
{
Int A, B, C, Max;
Printf ("\ n please enter three integers separated by spaces: \ n ");
Scanf ("% d", & A, & B, & C );
If (A> B) max =;
Else max = B;
If (max <c) max = C;
Printf ("the maximum value is % d \ n", max );
}
/* 3.6 calculates the maximum value among the three numbers. Similar to example 1.2 */
# Include <stdio. h>
Void main ()
{
Int A, B, C, Max;
Printf ("\ n please enter three integers separated by spaces: \ n ");
Scanf ("% d", & A, & B, & C );
Max = A> B? A: B;
Max = max> C? MAX: C;
Printf ("the maximum value is % d \ n", max );
}
/* 3.7 enter X to calculate the value of Y. Similar to example 3.13, you can also use the switch statement */
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Float X, Y;
Printf ("\ n please input a real number: \ n ");
Scanf ("% F", & X );
If (x> = 0 & x <10)
Y = sin (X );
If (x> = 10 & x <20)
Y = cos (X );
If (x> = 20 & x <30)
Y = exp (x)-1;
If (x> = 30 & x <40)
Y = Log (x + 1 );
If (x <0 | x> = 40)
Printf ("undefined ");
Else
Printf ("Y = % F \ n", y );
}
/* 3.7 enter X to calculate the value of Y. Similar to example 3.13, solution 2 */
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Float X, Y;
Printf ("\ n please input a real number: \ n ");
Scanf ("% F", & X );
If (x> 0 & x <= 40)
Switch (INT) (X/10 ))
{
Case 0: Y = sin (x); printf ("Y = % F \ n", Y); break;
Case 1: Y = cos (x); printf ("Y = % F \ n", Y); break;
Case 2: Y = exp (x)-1; printf ("Y = % F \ n", Y); break;
Case 3: Y = Log (x + 1); printf ("Y = % F \ n", Y); break;
}
Else
Printf ("undefined ");
}
/* 3.7 enter X to calculate the value of Y. Solution 3 */
# Include <stdio. h>
# Include <math. h>
Void main ()
{
Float X, Y;
Scanf ("% F", & X );
If (x <0 | x> = 40)
Printf ("no definition \ n ");
Else if (x> 30)
Y = Log (x + 1 );
Else if (x> 20)
Y = exp (x)-1;
Else if (x> 10)
Y = cos (X );
Else
Y = sin (X );
If (x> = 0 & x <40)
Printf ("Y = % F \ n", y );
}
/* 3.8 enter a percentage system score and give a prompt. Similar to example 3.14, you can also use the switch statement */
# include "stdio. H "
void main ()
{< br> int score;
printf (" enter a score (integer), for example 85 \ n ");
scanf ("% d", & score);
If (score> = 90 & score <= 100)
printf ("Excellent \ n");
If (score> = 80 & score <= 89)
printf ("good \ n ");
If (score> = 70 & score <= 79)
printf ("Middle \ n ");
If (score >=60 & score <= 69)
printf ("Pass \ n");
If (score <60)
printf ("fail \ n");
}