【正文】
s zero!\n )。 printf ( \n About the set of two liner equations:\n )。 scanf ( %f, amp。m )。 printf ( m = )。 scanf ( %f, amp。c )。 printf ( c = )。 scanf ( %f, amp。a )。 printf ( a = )。 printf ( \tax1+bx2=m\n\tcx1+dx2=n\n )。 } 6/2/2022 Chapter 5 Decision Making and Branching A set of two liner equations with two unknown x1 and x2 is given below: ax1 + bx2 = m cx1 + dx2 = n The set has a unique solution provided the denominator adcb is not equal to zero. Write a program that will read the values of constants a, b, c, d, m and n and pute the values of x1 and x2. An appropriate message should be printed if adcb=0. cbadmaxcbadbnmdx??????216/2/2022 Chapter 5 Decision Making and Branching main ( ) { float a, b, c, d, m, n。 if ( n % 2 ) printf ( %d IS ODD\n, n )。 scanf ( %d, amp。 } 6/2/2022 Chapter 5 Decision Making and Branching main ( ) /* (b) */ { int n。 if ( n % 2 ) printf ( %d IS ODD\n, n )。 scanf ( %d, amp。 and print the message NUMBER IS EVEN or NUMBER IS ODD (a) without using else option, and (b) with else option. 6/2/2022 Chapter 5 Decision Making and Branching main ( ) /* (a) */ { int n。 of 39。 } 6/2/2022 Chapter 5 Decision Making and Branching Write a program to determine whether a given number is 39。 printf ( Add them\t%6d\n, y*x)。 printf ( %d*%d is\t\t%5d\n, y/10, x, y/10*x )。 printf ( \t\t______\n)。y )。 scanf ( %d%d, amp。 } 6/2/2022 Chapter 4 Managing Input and Output Operations Write an interactive program to demonstrate the process of multiplication. The program should ask the user to enter two twodigit integers and print the product of integers as shown below. 45 37 7 45 is 315 3 45 is 135 Add them 1665 6/2/2022 Chapter 4 Managing Input and Output Operations main ( ) { int x, y, m, n。x )。 printf ( Please input the number: )。 printf ( (c) (x+y)(xy) = %f\n, (x+y)*(xy) )。 printf ( (a) (x+y)/(xy) = %f\n, (x+y)/(xy) )。 scanf ( %f, amp。x )。 printf ( x = )。6/2/2022 Programming Exercises North China Electric Power University 6/2/2022 Chapter 4 Managing Input and Output Operations Write a program to read the values of x and y and print the results of the following expressions in one line: (a) (b) (c) yxyx??2yx?))(( yxyx ??6/2/2022 Chapter 4 Managing Input and Output Operations main ( ) { float x, y。 printf ( Please input the value of x and y:\n )。 scanf ( %f, amp。 printf ( y = )。y )。 printf ( (b) (x+y)/2 = %f\n, (x+y)/2 )。 } 6/2/2022 Chapter 4 Managing Input and Output Operations Write a program to read the following numbers, round them off to the nearest integers and print out the results in integer form: 6/2/2022 Chapter 4 Managing Input and Output Operations main ( ) { float x。 scanf ( %f, amp。 printf ( The number is: %.0f\n , x )。 printf ( Please input 2 twodigit integers: )。x, amp。 printf ( \n\t\t%6d\n\t\t*%5d\n, x, y )。 printf ( %d*%d is\t\t%6d\n, y%10, x, y%10*x )。 printf ( \t\t______\n)。 printf ( \t\t______\n)。odd39。even39。 printf ( Please input an integer: )。n )。 if ( n % 2 == 0 ) printf ( %d IS EVEN\n, n )。 printf ( Please input an integer: )。n )。 else printf ( %d IS EVEN\n, n )。 printf ( About a set of two liner equations:\n )。 printf ( Please input the value of a, b, c, d, m and n:\n )。 scanf ( %f, amp。 printf ( b = )。b )。 scanf ( %f, amp。 printf ( d = )。d )。 scanf ( %f, amp。 printf ( n = )。n )。 printf(\t%.2fx1+%.2fx2=%.2f\n\t%.2fx1+%.2fx2=%.2f\n,a,b,m,c, d,n)。 else printf (The result: x1 = %.2f, x2 = %.2f\n, (m*d b*n)/(a*d c*b), (n*a m*c)/(a*d c*b) )。 printf ( Please input scores of the 3 subject : )。 scanf ( %f, amp。 printf ( Physics: )。phy )。 scanf ( %f, amp。 if ( math=60 amp。 phy=50 amp。 chem=40 amp。 (math+phy+chem=200 || math+phy=150) ) printf ( Admitted!\n )。 } 6/2/2022 Chapter 5 Decision Making and Branching A cloth showroom has announced the following seasonal discounts on purchase of items: Write a program using switch and if statements to pute the amount to be paid by a customer. Purchase amount Discount Mill cloth Handloom items 0~100 5% 101~200 5% % 201~300 % % Above 300 % % 6/2/2022 Chapter 5 Decision Making and Branching main ( ) { float price, discount。 printf ( Category (m/h): )。category )。 scanf ( %f, amp。 if ( category == 39。 ) switch ( (int) (price1)/100 ) { case 0: discount = 0。 case 1: discount = 。 case 2: discount = 。 default: discount = 。 break。 break。 break。 } printf ( The amount to be paid is %.2f\n, price*(1discount))。 printf ( Please input the value of x: )。x )。 else printf ( y = 1\n )。 } 6/2/2022 Chapter 5 Decision Making and Branching main ( ) /* (b) */ { float x。 scanf ( %f, amp。 if ( x 0 ) printf ( y = 1\n )。 else printf ( y = 1\n )。 printf ( Please input the value of x: )。x )。 } 6/2/2022 Chapter 5 Decision Making and Branching Write a program to pute the real roots of a quadratic equation The roots are given by the equations The program should request for the values of the constants a, b and c and print the values of x1, and x2. Use the following rules: (a) No solution, if both a and b are zero (b) There is only one root, if a=0 (x=c/b) (c) There are no real roots, if b24ac is negative (d) Otherwise, there are two real roots Test your program with appropriate data so that all logical paths are working as per your design. Incorporate appropriate output message