1896 Shares

Can anyone help me solve the errors in this programming problem? I've tried to debug for hours?

Can anyone help me solve the errors in this programming problem? I've tried to debug for hours? Topic: Problem solving using c programming
July 17, 2019 / By Artur
Question: include #define NROWS 2 #define NCOLS 2 void norm_2D(double x[NROWS][NCOLS]); int main() { int i, j, k; double x[NROWS][NCOLS]; int *ptr=&x[0][0]; double minx = x[0][0]; double maxx = x[0][0]; //Entering values for each element of array// for(i=0; i *(ptr+k)) minx = *(ptr+k); //Finding the maximum value of array x// for(k=0; k<=4; k++) if(maxx < *(ptr+k)) maxx = *(ptr+k); //Normalizing each element of array// for(i=0; i
Best Answer

Best Answers: Can anyone help me solve the errors in this programming problem? I've tried to debug for hours?

Ursula Ursula | 4 days ago
1) you need a pounds sign before the includes. 2) since x is an array of doubles, ptr needs to be a double *. 3) All the rest of your problems are caused by the norm_2D function. The function parameter is screwed up. double x[int i][int j] doesn't make any sense. Looking at the other declarations and the call its self, it is probably supposed to be void norm_2D(double x[NROWS][NCOLS]); 4) The body of norm_2D doesn't make any sense either. First, you call it with norm_2D(x[i][j]); which would pass in a double, but the rest of the program seems to show that you should be passing a 2d array. Also, is there a reason you have double nested for loops before you call it then again in the body of the loop? Also minx and maxx aren't ever declared within the function body. That function body needs a lot of work.
👍 96 | 👎 4
Did you like the answer? Can anyone help me solve the errors in this programming problem? I've tried to debug for hours? Share with your friends

We found more questions related to the topic: Problem solving using c programming


Ursula Originally Answered: C programming looping find max and min value problem help pls ~?
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 #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 , stud_max, stud_min; float gp, total_gp = 0; float gpa, average_gpa = 0, 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; stud_max = i + 1; //i++; } if (gpa < min) { min = gpa; stud_min = i + 1; //i++; } // Count subject countc++; // Calculate average gpa // Reset count & total_gp to 0 count = 0; total_gp = 0; } average_gpa = total_gpa / static_cast (countc); printf("\n"); printf("\nHighest GPA = %.1f obtain by Student No %d", max, stud_max); printf("\nLowest GPA = %.1f obtain by Student No %d", min, stud_min); printf("\nAverage GPA = %.1f", average_gpa); printf("\n"); return 0; }
Ursula Originally Answered: C programming looping find max and min value problem help pls ~?
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 x[i]) minValue = x[i]; if(maxValue < x[i]) maxValue = x[i]; }

Ursula Originally Answered: How to solve each problem?
8.) Solve the system of equations. 4x+5y=3 2x+y=0 --> x=-.5; y= 1; 9.) A possible step toward solving these equations by addition could be : 4y-6x=11 -8x-4y=13 --> -14x = 24 10.) Given the coordinate points A(2,4), C(3,6), and F(4,8), which equation proves that point C lies on the line AF? --> d(A,C)+d(C,F)=d(A,F) 11.) From this trinomial you can deduce that: x to the second power - 6x + 9=0 --> x = 3 12.) Factor the polynomial completely. --> 49s+7rs - 21 - 3r = 7s(7+r) - 3(7+r) = (7s-3)(7+r) 13.) Factor completely. 12x^2 +13x +3 = (4x+3)(3x+1)
Ursula Originally Answered: How to solve each problem?
a million. gas weights 0.69g/cm^3. If a automobile has 40 L gas tank, how plenty greater advantageous weight, in kilograms, is the automobile pulling while the gas tank is completed? by way of fact that a million Liter is a million,000 cm^3, One Liter of gas weights 690 grams or 0.sixty 9 kilograms. 40 L is 27.6 kilograms 2. A race automobile reaches a velocity of one hundred sixty miles in keeping with hour. what's the fee of velocity in keeping with minute? one hundred sixty miles in keeping with hour x ( one hour/60 minutes) = 2.sixty seven miles in keeping with minute 3. A 12 foot ladder is 12 foot x (12 inches in keeping with foot) = one hundred forty four inches. A 12 foot ladder is in simple terms too short.

If you have your own answer to the question problem solving using c programming, then you can write your own version, using the form below for an extended answer.