having problems with starting off code, should be pretty simple

This is a discussion on having problems with starting off code, should be pretty simple within the C Programming forums, part of the General Programming Boards category; i'm completly clueless, and i need to have this done by wednesday next week (ya it's an assignement) i want ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Posts
    1

    having problems with starting off code, should be pretty simple

    i'm completly clueless, and i need to have this done by wednesday next week (ya it's an assignement) i want to learn how to do this, because it surely wont be the last lab this semester,


    A program is needed to create a linear model using the least-squares technique presented in class for the following temperature measurements obtained by the weather balloon in the stratosphere:
    Altitude Temperature
    (km) (oC)
    20 -50
    30 -40
    40 -20
    50 -2
    Over this region of the atmosphere, these data are nearly linear, and thus we can use a linear model to estimate the temperature at altitudes other than ones for which we have specific data. Use two one-dimensional arrays to store the data shown above (hard-coded). Your program must compute the linear model from these data points, print the model to the screen with the beginning and ending altitudes to indicate the region over which the model is valid. In a loop, your program must then prompt the user for an altitude and compute and print to the screen the temperature at the desired altitude. Your program must validate the userís entry with respect to the range of validity of the model. Looping and your program ends when the user enters a negative value for the altitude.


    After what i can see, i need to calculate the best ajusted line for the information given
    i have a formula that i can put in the program,


    after wards, the user can input an information (altitude) and the program will give him the temperature



    WHERE DO I START AND explain arrays to me please

  2. #2
    The C eater *munch*
    Join Date
    Oct 2006
    Posts
    101
    simple array
    Code:
    #include <stdio.h>
    
    int main() {
       int myFirstArray[10]; // static array is basically a 'box' containing 
                             // variables of a type with certain size, array 
                             // index starts from 0 to SIZE - 1 (in this case 9)
       
       myFirstArray[0] = 10; // this is one way of assigning 
                             // a value to an array
    
       myFirstArray[0] = 10 * 10; // you can also do computation of element
    
       scanf("%d", &myFirstArray[1]); // you can prompt input from 
                                      // the user, this is saying :
                                      // get the input from the stdin (user) and 
                                      // assign it to the element number 1
    
       printf("%d\n", myFirstArray[0]); // to print the value of certain element
       
       return 0;
    }
    Last edited by yxunomei; 10-17-2006 at 08:07 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 19
    Last Post: 05-30-2007, 05:47 PM
  2. More Array code problems
    By Masa in forum C++ Programming
    Replies: 1
    Last Post: 04-08-2004, 02:04 AM
  3. << !! Posting Code? Read this First !! >>
    By kermi3 in forum Windows Programming
    Replies: 0
    Last Post: 10-14-2002, 01:29 PM
  4. problems with output from code
    By simhap in forum C++ Programming
    Replies: 0
    Last Post: 10-08-2001, 12:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21