4931 Shares

Topic: **Uppercase string****Question:**
First pls view my below codes...
#include
#include
#include
#include
#include
#define CLASS_SIZE 60
#define subjects 5
//===================================...
int main(void) {
char input[CLASS_SIZE][subjects], token[81];
int c_size;
int i, j;
float gp, total_gp = 0;
float gpa, average_gpa, total_gpa = 0;
int count = 0, countc = 0, run = 1;
float min, max;
//==================================...
// Ask for class size
printf("Input class size (num of students): ");
scanf("%d", &c_size);
// Looping grade question
for(i=0; i max)
{
max = gpa;
i++;
}
if (gpa < min)
{
min = gpa;
i++;
}
// Count subject
countc++;
// Calculate average gpa
average_gpa = total_gpa / countc;
printf("\n");
// Reset count & total_gp to 0
count = 0;
total_gp = 0;
}
printf("\nHighest GPA = %.1f obtain by Student No %d", max, i);
printf("\nLowest GPA = %.1f obtain by Student No %d", min, i);
printf("\nAverage GPA = %.0f", average_gpa);
return 0;
}
______________________________________...
My problem is I could not finds the the highest gpa value and lowest gpa value which obtain by a students. It always display the last student gpa value as a result...pls help. Very thanks you.

May 26, 2019 / By Florette

From what I see there are a couple of errors. 1. run should change value after "if" if(run == 1) { max = gpa; min = gpa; } 2. you should have a stud_max and stud_min variable so don't get same student max and min 3. you should calculate average out of the "for" loop 4. printf("\nAverage GPA = %.0f", average_gpa); should be printf("\nAverage GPA = %.1f", average_gpa); to get the average's decimal point I fixed that for you and now it works ;-) : #include

👍 176 | 👎 4

Did you like the answer? We found more questions related to the topic: **Uppercase string**

No one will write the whole program for you - and that would be cheating anyway - but it's pretty simple to do yourself - write a for loop to find the target string first - then when you get that working add a second part that does the substitution.

The idea of homework is that YOU practise what has been covered in class to reinforce the concepts. If you leech of others you will never learn to do it for yourself. At least post your code, it will be easier to help you by seeing where you are going wrong. The function as described is inpractical in the real world. It would more than likely take the text to be replaced as an input parameter rather than being fixed. PSEUDO CODE declare censor as FUNCTION( input parameter text type string) returning string declare pointer as pointer to string pointer = find 'foo' in text IF ( pointer is valid ) THEN ..LOOP WHILE ( pointer is valid ) ....replace 3 characters starting at pointer with 'xxx' ....pointer = find 'foo' in text ..END LOOP END IF return text

You have to study (read manuals and books) or hire programmer. Look for the last one at ScriptLance.com.

Hm.... the challenge is: After u declare minValue or maxValue, it would properly be random fee, rely u r compiler. celebration, if compiler says: minValue = lowest fee of double and if compiler says: maxValue = maximum fee of double - seem at form of double. U have trojan horse issues! fix with: make certain minValue and maxValue as first fee of array: double minValue = x[0]; double maxValue = x[0]; After this: for (i=a million; i

👍 70 | 👎 -2

Let A be the number of Model A dishwasher units. Likewise let B be the number of Model B dishwasher units. Let P(x,y) be the profit function We wish to maximize P(x,y) = $24A + $36B "the owner keeps at least twice as many of model a as model b" 2A = B The warehouse can store up to 36 units. So, A + B ≤ 36 Since 2A = B, we must consider the constraints on the number of units for A and B. A + 2A = 3A ≤ 36 A ≤ 12 B/2 + B ≤ 36 3B/2 ≤ 36 B ≤ 24 ___ Maximize P(x,y) = $24A + $36B subject to A + B ≤ 36 A ≤ 12 B ≤ 24 Solving this, you should find a global maximum at (A,B) = (12, 24). P(12, 24) = $ 1152

If you have your own answer to the question uppercase string, then you can write your own version, using the form below for an extended answer.