【正文】
ks in Chemistry = 40 (d) Total in all three subjects = 200 or Total in Mathematics and Physics = 150 Given the marks in the three subjects, write a program to process the applications to list the eligible candidates. 6/2/2022 Chapter 5 Decision Making and Branching main ( ) { float math, phy, chem。 printf ( Chemistry: )。amp。 printf ( Price: )。 break。 case 2: discount = 。 if ( x != 0 ) { if ( x 0 ) printf ( y = 1\n )。 else if ( x == 0 ) printf ( y = 0\n )。 printf ( Please input the value of a, b and c in the quadratic equation:\n ax*x + bx + c = 0\n )。 scanf ( %f, amp。 if ( f 0 ) printf(There are no real roots!\n)。 /* number is decreased by 10 times */ } } 6/2/2022 Chapter 6 Decision Making and Looping The factorial of an integer m is the product of consecutive integers from 1 to m. That is, factorial m = m! = m (m1) …… 1. Write a program that putes and prints a table of factorials for any given m. 6/2/2022 Chapter 6 Decision Making and Looping main ( ) { int m。 } printf ( %ld\n, n )。 /* number is decreased by 10 times */ } printf ( The sum of the digits is %d.\n, sum )。 f = f1 + f2。 scanf ( %f %d, amp。 x to power n = %f\n, x, n, y )。 n = 8。 n = 8。 for ( i = 1。 i = 1。 } } 6/2/2022 Chapter 6 Decision Making and Looping Write a program to read the age of 100 persons and count the number of persons in the age group 50 to 60. Use for and continue statements. 6/2/2022 Chapter 6 Decision Making and Looping main ( ) { int age, count = 0, i。 } printf ( The number of persons in the age group 50 to 60 is %d.\n, count )。 for ( i = 1。 j++ ) { x = i + *j。 scanf ( %ld, amp。 i ) { n = number。 i++ ) { printf ( \n )。 j = 18。 i = m。 } e=1+1/1!+1/2!+1/3!+1/4!+1/5!+1/6!+1/7!+1/8!+1/9!= 6/2/2022 Chapter 6 Decision Making and Looping The present value (popularly known as book value) of an item is given by the relationship. P = c(1d)n where c = original cost d = rate of depreciation (per year) n = number of years P = present value after n years If P is considered the scrap value at the end of useful life of the item, write a program to pute the useful life in years given the original cost, depreciation rate, and the scrap value. The program should request the user to input the data interactively. 6/2/2022 Chapter 6 Decision Making and Looping main ( ) { float c, d, p。 printf ( The number of years is: )。spoilt ballot39。amp。 count ++ ) printf(Candidate%3d ballots: %d \n,count,candidate[count])。 j++ ) if ( j == 0 || i == j ) p[i][j] = 1。 } } 6/2/2022 Chapter 7 Arrays The annual examination results of 100 students are tabulated as follows: Write a program to read the data and determine the following: (a) Total marks obtained by each student. (b) The highest marks in each subject and the Roll No. of the student who secured it. (c) The student who obtained the highest total marks. Roll No. Subject 1 Subject 2 Subject 3 6/2/2022 Chapter 7 Arrays define N 100 main ( ) { float s[N][4] = {0}, m[N] = {0}, max。 printf(The mark of Subjcet 1 : )。 printf(The mark of Subjcet 3 : )。 j = 3。 i ++ ) if ( m[i] max ) { max = m[i]。a[i] )。 k++ ) { if ( b[j] a[i] amp。 } } printf(The merged numbers are: )。 i ++ ) for ( j = 0。 j N。 j++ ) { for ( k = 0, c[i][j] = 0。 i ++ ) for ( j = 0。 j++ ) printf ( %3d, a[i][j] )。 for( i = 1。 a[Ni] = t。 i++ ) scanf ( %d, amp。 } t = a[k]。n)。 } while ( i = j )。 while( name [i] != 39。 break。 gets ( str )。 for ( i = n 1。 gets ( str )。 i++。 } 6/2/2022 Chapter 8 Character Arrays and Strings Write a program which will read a string and rewrite it in the alphabetical order. For example, the string STRING should be written as GINRST. 6/2/2022 Chapter 8 Character Arrays and Strings include main ( ) /* Bubble sort 。 } else break。 gets ( word )。amp。 scanf ( %d, amp。 else { printf ( Try again! )。 ) printf ( %4d, name[i++] )。 else printf( Not found!\n )。 j = N 1。 a[Ni] = t。 for( i = 1。 i N。 i++ ) { k = 0。 } } 6/2/2022 Chapter 7 Arrays Selection sort is based on the following idea: Selecting the largest array element and swapping it with the last array element leaves an unsorted list whose size is 1 less than the size of the original list. If we repeat this step again on the unsorted list we will have an ordered list of size 2 and an unordered list size n2. When we repeat this until the size of the unsorted list bees one, the result will be a sorted list. Write a program to implement this algorithm. 6/2/2022 Chapter 7 Arrays define N 10 main() { int a[N], i, j, t, k。 j++ ) if ( i + j N 1 ) a[i][j] = 1。 k ++ ) c[i][j] += a[i][k] * b[k][j]。b[i][j] )。 j++ ) scanf ( %d, amp。 k M + N。 j N || i = M ) { c[k] = b[j]。 for ( j = 0。 } printf ( The student % obtained the highest total marks.\n, s[k][0] )。 i N。s[i][3])。s[i][1])。 printf(Please input the roll number and marks of %d students.\n, N)。 for ( i = 0。 } 6/2/2022 Chapter 7 Arrays The following set of numbers is popularly known as Pascal39。 else spoilt ++。 printf ( Please input the votes (1~5) and press 39。n )。 printf ( The original cost of the item is: )。 item = / n。 } } 6/2/2022 Chapter 6 Decision Making and Looping Write a program to pute the value of Euler39。amp。 j i。 n = number。 } } for ( i = 1。 i++ ) printf ( \t0.%d, i)。 int i, j。 i = 100。 j = 5 i。 i++ ) { for ( j = 1。 pp = v。 else printf ( %d years, n )。 fl