Friday, 15 April 2011

c - Having trouble using if statement with for loop and arrays -


I have a problem in one of my tasks here is the code:

  included & Lt; Stdio.h & gt; Include & lt; Math.h> Include & lt; Stdlib.h & gt; Int inputount (int i); Zero input (double data [], int j); Double Fartole (double data [], int j); Zero output fahr (double data [], int nuffar); Zero Output Allowed (Double Data [], Intimate Nuffarrs); Zero Output Highlight (Double Data [], Int Newfahar); Zero Outputgrad (double data [], int NFhurs); Int main (zero) {int i, j, numfahrs; Double data [i], * ptr = & amp; Data [i]; I = inputAmount (i); Printf ("% d \ n \ n", i); InputFairers (and data [i], i); Data [j] = fartosel (and data [i], j); Printf ("% 1f", data [j]); Return 0; } Int inputAmount (int i) {printf ("Please enter the amount of quantities to be used. \ N \ n"); Scanf ("% d", & amp; i); While (i and lt; 1 || i> 25) {printf ("Value is out of range, please enter other values. \ N \ n"); Scanf ("% d", & amp; i); } Came back; } Zero inputfrom (double data [], int i) {int j; Printf ("Enter the temperature values ​​in the range of -175 to 175 degrees F. \ n \ n"); For (j = 0; j  175} {printf ("the price of the temperature is out of range. Please re-enter"); Scanf ("% F", and data [ja]); }}} Double Fertosel (double data [], int j) {int i; Printf ("test"); {Data {i] = (((data (i)) - 32) * (5.0 / 9.0) for (J = 1; J & lt; = I; J ++); } Return figure [i]; }   

Basically the issue in my code is that if I leave this code entirely if leave the statement I want to go to the program loop and If the user enters the value outside a certain range, then I want the if statement to start a statement inside a loop, but a statement of statement in the statement if If there is something wrong with it then I can replace the location of if has also tried to loop

The problem is that you

i

j Using a subscript will work

scanf ("% f", and data [j])

if (data [j] 175)

should work because the data [i] is not a possible subcript value, because I have the array size

and why you use the line Have done

  data [i] = data [i];   

?

No comments:

Post a Comment