Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP) 
Author Message
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

I amm getting a lot of compiler errors which i have no idea how to
fix. I am sending you my whole code and please help me fix my errors.
Mostly those that say that else is not a valid statement and that i
did not close the parentheses when i did.
Thankyou.

Here is my code:

/* Name: Lior Prosor                      */
/* Login ID: bp106239                     */
/* Student ID: 017000766                  */
/* Program Description: As a weather forecasting program, this program
will
   recieve input from certain measuring devices. Using the data from
these
   devices the program will both print out the data that the devices
had
   provided and give a detailed forecast. */

#include<stdio.h>
#define MIN 1.0/60.0
main()
{
  int month1, day1, day2, year1, hour1, hour2, minute1, minute2,
barp1,
      barp2, wind1, wind2;
  float bartend;
  scanf("%d/%d/%d %d:%2d", &month1, &day1, &year1, &hour1, &minute1);
  scanf("%d %d", &barp1, &wind1);
  scanf("%d/%d/%d %d:%d", &month1, &day2, &year1, &hour2, &minute2);
  scanf("%d %d", &barp2, &wind2);

/* This part of the program reads in all the values from the input and
     assigns them to various integer names */

  if (year1 < 2000 && year1 >= 1950) {
    printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1, \
           year1 + 1900, hour1, minute1);
  } else {
    printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1,
year1 + 200\
            0, hour1, minute1);
  }

 /* Prints out the date and the time of the current observation */

bartend= ((1.0*barp1-barp2)/((1.0*hour1+(minute1*MIN))-(hour2+(minute2*MIN)))\
           );

  if (bartend >= 1 && bartend < 2) {
     printf("Barometer: %d millibars, rising slowly (%f mb/hr)\n",
barp1, barte\
            nd);
  } else if (bartend >=2) {
        printf("Barometer: %d millibars, rising rapidly (%f mb/hr)\n",
barp1,  \
              bartend);
  } else if (bartend <= -1 && bartend > -2) {
         printf("Barometer: %d millibars, falling slowly (%f
mb/hr)\n", barp1, \
                bartend);
  } else if (bartend <= -2) {
         printf("Barometer: %d millibars, falling rapidly (%f
mb/hr)\n", barp1,\
                  bartend);
  } else if (bartend < 1 II bartend > -1) {
         printf("Barometer: %d millibars, falling slowly (%f
mb/hr)\n", barp1, \
                bartend);
  }

/* Checks the barometric tendency and prints it out with the current
    observation's millibar reading. */

switch (wind1) {
    case 1: printf("Wind direction: SW\n");
            break;
    case 2: printf("Wind direction: S\n");
            break;
    case 3: printf("Wind direction: SE\n");
            break;
    case 4: printf("Wind direction: W\n");
            break;
    case 5: printf("Wind direction: calm (no wind)\n");
            break;
    case 6: printf("Wind direction: E\n");
            break;
    case 7: printf("Wind direction: NW\n");
            break;
    case 8: printf("Wind direction: N\n");
            break;
    case 9: printf("Wind direction: NE\n");
            break;
  }

/* This switch statement analyses the value inputted as integer wind1
and
   prints out the wind direction in words converting it from its
number status
   in the input */

  printf("\n****FORECAST****\n");

if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1019 && barp1
<= 1023)\
      && (bartend < 1 || bartend > -1)) {
     printf("Fair with no significant temperature change for 1 to 2
days\n");
     printf("We are happy to provide this forecast.\n");
  }  else if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1019
&& barp1 \
              <= 1023) && (bartend >=2) {
     printf("Fair; rain within 48 hours\n");
     printf("We are happy to provide this forecast.\n");
  }  else if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1023)
&&      \
             (bartend < 1 || bartend > -1)) {
     printf("Fair with no significant temperature change for 1 to 2
days\n");
     printf("We are happy to provide this forecast.\n");
  }  else if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1023)
&&      \
             (bartend <= -1 && bartend > -2)) {
     printf("Fair with slowly rising temperature\n");
     printf("We are happy to provide this forecast.\n");
  }  else if ((wind == 2 || wind == 3) && (barp1 >= 1019 && barp1 <=
1023) &&  \
             (bartend <= -1 &&  bartend > -2)) {
     printf("Rain within 24 hours\n");
printf("We are happy to provide you with this foecast\n");
  }  else if ((wind == 2 || wind == 3) && (barp1 >= 1019 && barp1 <=
1023) &&  \
             (bartend <= -2)) {
     printf("Wind increasing, rain within 12 to 24 hours\n");
     printf("We are happy to provied you with this forecast\n");
  }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 >= 1019
&&       \
              barp1 <= 1023) && (bartend <= -1 &&  bartend > -2)) {
     printf("Rain in 12 to 18 hours\n");
     printf("We are happy to provied you with this forecast\n");
  }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 >= 1019
&&       \
             barp1 <= 1023) && (bartend <= -2)) {
printf("Wind increasing, rain within 12 hours\n");
     printf("We are happy to provide you with this forecast\n");
  }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 <= 1016)
&&      \
             (bartend <= -1 &&  bartend > -2)) {
     printf("Rain continuing 1 to 2 days\n");
     printf("We are happy to provied you with this forecast\n");
  }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 <= 1016)
&&      \
             (bartend <= -2)) {{
          if (month1 == 12 || month1 == 1 || month1 == 2)
          printf("Rain and windy; clearing and colder within 36
hours\n");
          printf("We are happy to provide you with this forecast\n");

Quote:
}    else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 <= 1016)

&&    \
               (bartend <= -2)) {
     printf("Rain and windy; clearing within 36 hours\n");
     printf("We are happy to provide you with this forecast\n");
  }}  else if ((wind == 1 || wind == 2) && (barp1 <= 1016) && (bartend
Quote:
>= 1 && \

              bartend < 2)) {
     printf("Clearing within a few hours then fair\n");
     printf("We are happy to provide you with this forecast\n");
  }
     else if ((wind == 2 || wind == 1) && (barp1 <= 1009) && (bartend
<= -2)){{
          if (month1 == 12 || month1 == 1 || month1 == 2)
printf("Severe storm, clearing and colder within 24 hours\n");
          printf("We are happy to provide you with this forecast\n");
     }    else if ((wind == 2 || wind == 1) && (barp1 <= 1009) &&
(bartend <=  \
                 -2)) {
          printf("Severe storm, clearing within 24 hours\n");
          printf("We are happy to provide this forecast\n");
 }}  else if ((wind == 6 || wind == 8) && (barp1 <= 1009) && (bartend
<= -2)){{
          if (month1 == 12 || month1 == 1 || month1 == 2)
          printf("Severe northeast gale and heavy snow, followed by a
cold wave\
                \n");
          printf("We are happy to provide you with this forecast\n");
Quote:
}    else if ((wind == 6 || wind == 8) && (barp1 <= 1009) && (bartend

<=     \
               -2)) {
       printf("Severe northeast gale and heavy precipitation\n");
       printf("We are happy to provide this forecast\n");
  }} else if ((wind == 1 || wind == 7) && (barp1 <= 1009) && (bartend
Quote:
>= 2)) {

     printf("Clearing and colder\n");
     printf("We are happy to provied you with this forecast\n");
  }  else {
     printf("Sorry, we were unable to provide a forecast due to
incoreect input\
            \n");
  }
/* This sequence of if and else statements takes the wind direction,
the
        barometric pressure in millibars and the barometric tendency
measured
        in the previous section of the code and outputs a forecast
according
        to some forecasting rules */

return 0;

and my compiler errors:
cc: Error: project2.c, line 116: Invalid statement. (badstmt)
     else if ((wind1 == 2 || wind1 == 1) && (barp1 <= 1009) &&
(bartend <= -2))
            {{
-----^
cc: Error: project2.c, line 120: Invalid statement. (badstmt)
     }    else if ((wind1 == 2 || wind1 == 1) && (barp1 <= 1009) &&
(bartend <=
                  -2)) {
----------^
cc: Error: project2.c, line 123: Invalid statement. (badstmt)
 }}  else if ((wind1 == 6 || wind1 == 8) && (barp1 <= 1009) &&
(bartend <= -2))
            {{
-----^
cc: Error: project2.c, line 127: Invalid statement. (badstmt)
  }    else if ((wind1 == 6 || wind1 == 8) && (barp1 <= 1009) &&
(bartend <=
                -2)) {
-------^
cc: Error: project2.c, line 130: Invalid statement. (badstmt)
  }} else if ((wind1 == 1 || wind1 == 7) && (barp1 <= 1009) &&
(bartend >= 2))
             {
-----^
cc: Error: project2.c, line 133: Invalid statement. (badstmt)
  }  else {
-----^
***I cant even get all of them on one screen
Please Help



Fri, 26 Mar 2004 01:32:08 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

Quote:

> I amm getting a lot of compiler errors which i have no idea how to
> fix. I am sending you my whole code and please help me fix my errors.
> Mostly those that say that else is not a valid statement and that i
> did not close the parentheses when i did.
> Thankyou.

    In many places in that code, you have {{ when you should only have {
and }} when you should only have }.

--
Clark S. Cox III

http://www.whereismyhead.com/clark/



Fri, 26 Mar 2004 01:40:44 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

Quote:

>   if (year1 < 2000 && year1 >= 1950) {
>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1, \
>            year1 + 1900, hour1, minute1);

So if the year is between 1950 and 2000 you add 1900 to it?  How
bizarre.

Quote:
>   } else {
>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1,
> year1 + 200\
>             0, hour1, minute1);

Why the random line break with \?

Quote:
>   }

>  /* Prints out the date and the time of the current observation */

> bartend= ((1.0*barp1-barp2)/((1.0*hour1+(minute1*MIN))-(hour2+(minute2*MIN)))\
>            );

Again a random line break.  You really like backslashes or what?
Also some white space would help readability here.  I have no
idea what you're trying to calculate.  Something about bartending
maybe; drinks served per unit time?

Quote:
>   if (bartend >= 1 && bartend < 2) {
>      printf("Barometer: %d millibars, rising slowly (%f mb/hr)\n",
> barp1, barte\
>             nd);
>   } else if (bartend >=2) {
>         printf("Barometer: %d millibars, rising rapidly (%f mb/hr)\n",
> barp1,  \
>               bartend);
>   } else if (bartend <= -1 && bartend > -2) {
>          printf("Barometer: %d millibars, falling slowly (%f
> mb/hr)\n", barp1, \
>                 bartend);
>   } else if (bartend <= -2) {
>          printf("Barometer: %d millibars, falling rapidly (%f
> mb/hr)\n", barp1,\
>                   bartend);
>   } else if (bartend < 1 II bartend > -1) {
>          printf("Barometer: %d millibars, falling slowly (%f
> mb/hr)\n", barp1, \
>                 bartend);
>   }

You should put this sequence of if/else statements in some kind
of sensible order, instead of this apparently random order.  That
way people reading your code (like me) would have a chance to
casually see that it doesn't have redundant ranges, etc., without
having to study it.

Quote:
> /* This switch statement analyses the value inputted as integer wind1

You should really put comments *above* what they're commenting
on.  Makes the program easier to read.

Quote:
>   printf("\n****FORECAST****\n");

> if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1019 && barp1
> <= 1023)\
>       && (bartend < 1 || bartend > -1)) {
>      printf("Fair with no significant temperature change for 1 to 2
> days\n");
>      printf("We are happy to provide this forecast.\n");

This sequence of if/else statements is totally incomprehensible.
I suggest switching to a data-driven scheme where you specify the
possibilities for wind, barp1, etc., in an array that points out
the correct forecast.  Also you really don't need to redundantly
say "We are happy to provide this forecast.\n" twenty or so
separate times.  Use a subroutine.

Quote:
> and my compiler errors:
> cc: Error: project2.c, line 116: Invalid statement. (badstmt)
>      else if ((wind1 == 2 || wind1 == 1) && (barp1 <= 1009) &&
> (bartend <= -2))
>             {{

Your parentheses and your braces are both unbalanced, is an error
message really a surprise?
--
"When in doubt, treat ``feature'' as a pejorative.
 (Think of a hundred-bladed Swiss army knife.)"
--Kernighan and Plauger, _Software Tools_


Fri, 26 Mar 2004 01:43:33 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)
Hiya,



Quote:
> I amm getting a lot of compiler errors which i have no idea how to
> fix. I am sending you my whole code and please help me fix my errors.
> Mostly those that say that else is not a valid statement and that i
> did not close the parentheses when i did.
> Thankyou.
> #include<stdio.h>
> #define MIN 1.0/60.0
> main()

Well, that's a good start. should be int main(void)

Quote:
> {
>   int month1, day1, day2, year1, hour1, hour2, minute1, minute2,
> barp1,
>       barp2, wind1, wind2;
>   float bartend;
>   scanf("%d/%d/%d %d:%2d", &month1, &day1, &year1, &hour1, &minute1);
>   scanf("%d %d", &barp1, &wind1);
>   scanf("%d/%d/%d %d:%d", &month1, &day2, &year1, &hour2, &minute2);
>   scanf("%d %d", &barp2, &wind2);

> /* This part of the program reads in all the values from the input and
>      assigns them to various integer names */

>   if (year1 < 2000 && year1 >= 1950) {
>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1, \
>            year1 + 1900, hour1, minute1);

What is the purpose of the \? In C, unless you have a #define construct or
a semicolon, the compiler won't be bothered by the white space. The above
should therefore be

 printf ("Current observation %d/%d/%d %d:%2d\n", month1, day1,
         year1 + 1900, hour1, minute1);

The 2.2d is pretty pointless as minute1 is an int.        

Quote:
>   } else {
>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1,
> year1 + 200\
>             0, hour1, minute1);

Same applies here.

Quote:
>  /* Prints out the date and the time of the current observation */

> bartend= ((1.0*barp1-barp2)/((1.0*hour1+(minute1*MIN))-(hour2+(minute2*MIN)))\
>            );

And again. However, this time, you need to promote barp1 etc to a float.
This will account for quite a few of the errors.

Quote:
>   if (bartend >= 1 && bartend < 2) {
>      printf("Barometer: %d millibars, rising slowly (%f mb/hr)\n",
> barp1, barte\
>             nd);

And again - infact, read "and again" for any other line breaks.

Quote:
>   } else if (bartend >=2) {
>         printf("Barometer: %d millibars, rising rapidly (%f mb/hr)\n",
> barp1,  \

<snip>

- Show quoted text -

Quote:

> /* Checks the barometric tendency and prints it out with the current
>     observation's millibar reading. */

> switch (wind1) {
>     case 1: printf("Wind direction: SW\n");
>             break;
>     case 2: printf("Wind direction: S\n");
>             break;
>     case 3: printf("Wind direction: SE\n");
>             break;
>     case 4: printf("Wind direction: W\n");
>             break;
>     case 5: printf("Wind direction: calm (no wind)\n");
>             break;
>     case 6: printf("Wind direction: E\n");
>             break;
>     case 7: printf("Wind direction: NW\n");
>             break;
>     case 8: printf("Wind direction: N\n");
>             break;
>     case 9: printf("Wind direction: NE\n");
>             break;
>   }

What happens if wind == 0?

I think most of the errors are down to the wrong placing of linebreaks.

Quote:
> ***I cant even get all of them on one screen Please Help

Re-write the code, omit the line breakers and try again. If you're still
hitting a brick wall, post the new code.

TTFN

Paul

--
Sent from the heart of British Technology at its best - the all
new RiscStation R7500 - now running with the new 50ns upgrade
All opinions expressed are solely mine and do not represent any
other persons or companies.



Fri, 26 Mar 2004 03:17:23 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

Quote:
> Hiya,


>> I amm getting a lot of compiler errors which i have no idea how to
>> fix. I am sending you my whole code and please help me fix my errors.
>> Mostly those that say that else is not a valid statement and that i
>> did not close the parentheses when i did.
>> Thankyou.
>>   if (year1 < 2000 && year1 >= 1950) {
>>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1, \
>>            year1 + 1900, hour1, minute1);
> What is the purpose of the \? In C, unless you have a #define construct or
> a semicolon, the compiler won't be bothered by the white space. The above
> should therefore be
>  printf ("Current observation %d/%d/%d %d:%2d\n", month1, day1,
>          year1 + 1900, hour1, minute1);

> The 2.2d is pretty pointless as minute1 is an int.        
>>   } else {
>>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1,
>> year1 + 200\
>>             0, hour1, minute1);
> Same applies here.

You missed the bug about the year numbers. If the year is within the
range [1950, 2000[ the program will display it as being within the
range [3850, 3900[. Otherwise it will display it as being either within
the range ]-inf, 3950[ or within the range [4000, +inf[.
This has two problematic areas: the years within the range [3850,
3900[ are ambiguous, and the years within the range [3950, 4000[ do
not exist.
(For those who have been taught The Other Way Of Expressing Sets,
read [A, B) where I have written [A, B[ and (A, B] where I have written
]A, B].)

--

| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste       W++ B OP+                     |
\----------------------------------------- Finland rules! ------------/

"'It can be easily shown that' means 'I saw a proof of this once (which I didn't
understand) which I can no longer remember'."
   - A maths teacher



Fri, 26 Mar 2004 03:28:26 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)


Quote:
> I amm getting a lot of compiler errors which i have no idea how to
> fix. I am sending you my whole code and please help me fix my errors.
> Mostly those that say that else is not a valid statement and that i
> did not close the parentheses when i did.
> Thankyou.

> Here is my code:

> /* Name: Lior Prosor                      */
> /* Login ID: bp106239                     */
> /* Student ID: 017000766                  */
> /* Program Description: As a weather forecasting program, this program
> will
>    recieve input from certain measuring devices. Using the data from
> these
>    devices the program will both print out the data that the devices
> had
>    provided and give a detailed forecast. */

> #include<stdio.h>
> #define MIN 1.0/60.0
> main()
> {
>   int month1, day1, day2, year1, hour1, hour2, minute1, minute2,
> barp1,
>       barp2, wind1, wind2;
>   float bartend;
>   scanf("%d/%d/%d %d:%2d", &month1, &day1, &year1, &hour1, &minute1);
>   scanf("%d %d", &barp1, &wind1);
>   scanf("%d/%d/%d %d:%d", &month1, &day2, &year1, &hour2, &minute2);
>   scanf("%d %d", &barp2, &wind2);

> /* This part of the program reads in all the values from the input and
>      assigns them to various integer names */

>   if (year1 < 2000 && year1 >= 1950) {
>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1, \
>            year1 + 1900, hour1, minute1);
>   } else {
>     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1,
> year1 + 200\
>             0, hour1, minute1);
>   }

>  /* Prints out the date and the time of the current observation */

> bartend=
> ((1.0*barp1-barp2)/((1.0*hour1+(minute1*MIN))-(hour2+(minute2*MIN)))\
>            );

You have a serious formatting problem. Try that

/* Name: Lior Prosor
 * Login ID: bp106239
 * Student ID: 017000766
 * Program Description: As a weather forecasting program, this program
 * will recieve input from certain measuring devices. Using the data
 * from these devices the program will both print out the data that
 * the devices had provided and give a detailed forecast.
 */

#include<stdio.h>

#define MIN 1.0/60.0

int main (void)
{
   int month1;
   int day1;
   int day2;
   int year1;
   int hour1;
   int hour2;
   int minute1;
   int minute2;
   int barp1;
   int barp2;
   int wind1;
   int wind2;

   float bartend;

   scanf ("%d/%d/%d %d:%2d", &month1, &day1, &year1, &hour1, &minute1);
   scanf ("%d %d", &barp1, &wind1);
   scanf ("%d/%d/%d %d:%d", &month1, &day2, &year1, &hour2, &minute2);
   scanf ("%d %d", &barp2, &wind2);

/* This part of the program reads in all the values from the input and
   assigns them to various integer names */

   if (year1 < 2000 && year1 >= 1950)
   {
      printf ("Current observation %d/%d/%d %d:%2.2d\n"
             , month1
             , day1
             , year1 + 1900
             , hour1
             , minute1);
   }
   else
   {
      printf ("Current observation %d/%d/%d %d:%2.2d\n"
             , month1
             , day1
             , year1 + 200
             , 0
             , hour1
             , minute1);
   }

   /* Prints out the date and the time of the current observation */

   bartend = ((1.0 * barp1 - barp2)
            / ((1.0 * hour1 + (minute1 * MIN))
             - (hour2 + (minute2 * MIN))));

   if (bartend >= 1 && bartend < 2)
   {
      printf ("Barometer: %d millibars, rising slowly (%f mb/hr)\n"
             , barp1
             , bartend);
   }
   else if (bartend >= 2)
   {
      printf ("Barometer: %d millibars, rising rapidly (%f mb/hr)\n"
             , barp1
             , bartend);
   }
   else if (bartend <= -1 && bartend > -2)
   {
      printf ("Barometer: %d millibars, falling slowly (%f mb/hr)\n"
             , barp1
             , bartend);
   }
   else if (bartend <= -2)
   {
      printf ("Barometer: %d millibars, falling rapidly (%f mb/hr)\n"
             , barp1
             , bartend);
   }
   else if (bartend < 1 || bartend > -1)
   {
      printf ("Barometer: %d millibars, falling slowly (%f mb/hr)\n"
             , barp1
             , bartend);
   }

/* Checks the barometric tendency and prints it out with the current
   observation's millibar reading. */

   switch (wind1)
   {
   case 1:
      printf ("Wind direction: SW\n");
      break;
   case 2:
      printf ("Wind direction: S\n");
      break;
   case 3:
      printf ("Wind direction: SE\n");
      break;
   case 4:
      printf ("Wind direction: W\n");
      break;
   case 5:
      printf ("Wind direction: calm (no wind)\n");
      break;
   case 6:
      printf ("Wind direction: E\n");
      break;
   case 7:
      printf ("Wind direction: NW\n");
      break;
   case 8:
      printf ("Wind direction: N\n");
      break;
   case 9:
      printf ("Wind direction: NE\n");
      break;
   }

/* This switch statement analyses the value inputted as integer wind1
   and prints out the wind direction in words converting it from its
   number status in the input */

   printf ("\n****FORECAST****\n");

   if ((wind2 == 1 || wind2 == 4 || wind2 == 7)
    && (barp1 >= 1019 && barp1 <= 1023)
    && (bartend < 1 || bartend > -1))
   {
      printf ("Fair with no significant temperature change for 1 to 2 "
              "days\n");
      printf ("We are happy to provide this forecast.\n");
   }
   else if ((wind2 == 1 || wind2 == 4 || wind2 == 7)
         && (barp1 >= 1019 && barp1 <= 1023) && (bartend >= 2))
   {
      printf ("Fair; rain within 48 hours\n");
      printf ("We are happy to provide this forecast.\n");
   }
   else if ((wind2 == 1 || wind2 == 4 || wind2 == 7)
         && (barp1 >= 1023)
         && (bartend < 1 || bartend > -1))
   {
      printf ("Fair with no significant temperature change for 1 to 2 "
              "days\n");
      printf ("We are happy to provide this forecast.\n");
   }
   else if ((wind2 == 1 || wind2 == 4 || wind2 == 7)
            && (barp1 >= 1023)
            && (bartend <= -1 && bartend > -2))
   {
      printf ("Fair with slowly rising temperature\n");
      printf ("We are happy to provide this forecast.\n");
   }
   else if ((wind2 == 2 || wind2 == 3)
         && (barp1 >= 1019 && barp1 <= 1023)
         && (bartend <= -1 && bartend > -2))
   {
      printf ("Rain within 24 hours\n");
      printf ("We are happy to provide you with this foecast\n");
   }
   else if ((wind2 == 2 || wind2 == 3)
        && (barp1 >= 1019 && barp1 <= 1023)
        && (bartend <= -2))
   {
      printf ("Wind increasing, rain within 12 to 24 hours\n");
      printf ("We are happy to provied you with this forecast\n");
   }
   else if ((wind2 == 3 || wind2 == 9 || wind2 == 6)
         && (barp1 >= 1019 && barp1 <= 1023)
         && (bartend <= -1 && bartend > -2))
   {
      printf ("Rain in 12 to 18 hours\n");
      printf ("We are happy to provied you with this forecast\n");
   }
   else if ((wind2 == 3 || wind2 == 9 || wind2 == 6)
         && (barp1 >= 1019 && barp1 <= 1023)
         && (bartend <= -2))
   {
      printf ("Wind increasing, rain within 12 hours\n");
      printf ("We are happy to provide you with this forecast\n");
   }
   else if ((wind2 == 3 || wind2 == 9 || wind2 == 6)
         && (barp1 <= 1016)
         && (bartend <= -1 && bartend > -2))
   {
      printf ("Rain continuing 1 to 2 days\n");
      printf ("We are happy to provied you with this forecast\n");
   }
   else if ((wind2 == 3 || wind2 == 9 || wind2 == 6)
         && (barp1 <= 1016)
         && (bartend <= -2))
   {
      if (month1 == 12 || month1 == 1 || month1 == 2)
      {
         printf ("Rain and windy; clearing and colder within 36 hours\n");
      }
      printf ("We are happy to provide you with this forecast\n");
   }
   else if ((wind2 == 3 || wind2 == 9 || wind2 == 6)
         && (barp1 <= 1016)
         && (bartend <= -2))
   {
      printf ("Rain and windy; clearing within 36 hours\n");
      printf ("We are happy to provide you with this forecast\n");
   }
   else if ((wind2 == 1 || wind2 == 2)
         && (barp1 <= 1016)
         && (bartend >= 1 && bartend < 2))
   {
      printf ("Clearing within a few hours then fair\n");
      printf ("We are happy to provide you with this forecast\n");
   }
   else if ((wind2 == 2 || wind2 == 1)
         && (barp1 <= 1009)
         && (bartend <= -2))
   {
      if (month1 == 12 || month1 == 1 || month1 == 2)
      {
         printf ("Severe storm, clearing and colder within 24 hours\n");
      }
      printf ("We are happy to provide you with this forecast\n");
   }
   else if ((wind2 == 2 || wind2 == 1)
         && (barp1 <= 1009)
         && (bartend <= -2))
   {
      printf ("Severe storm, clearing within 24 hours\n");
      printf ("We are happy to provide this forecast\n");
   }
   else if ((wind2 == 6 || wind2 == 8)
         && (barp1 <= 1009)
         && (bartend <= -2))
   {
      if (month1 == 12 || month1 == 1 || month1 == 2)
      {
        printf ("Severe northeast gale and heavy snow, "
                "followed by a cold wave\n");
      }
      printf ("We are happy to provide you with this forecast\n");
   }
   else if ((wind2 == 6 || wind2 == 8)
         && (barp1 <= 1009)
         && (bartend <= -2))
   {
      printf ("Severe northeast gale and heavy precipitation\n");
      printf ("We are happy to provide this forecast\n");
   }
   else if ((wind2 == 1 || wind2 == 7)
         && (barp1 <= 1009)
         && (bartend >= 2))
   {
      printf ("Clearing and colder\n");
      printf ("We are happy to provied you with this forecast\n");
   }
   else
   {
      printf ("Sorry, we were unable to provide a forecast due to "
              "incoreect input\n");
   }

/* This sequence of if and else statements takes the wind direction,
   the barometric pressure in millibars and the barometric tendency
   measured in the previous section of the code and outputs a
   forecast according to some forecasting
...

read more »



Fri, 26 Mar 2004 03:38:54 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)
Hiya,



Quote:
> You missed the bug about the year numbers. If the year is within the
> range [1950, 2000[ the program will display it as being within the range
> [3850, 3900[. Otherwise it will display it as being either within the
> range ]-inf, 3950[ or within the range [4000, +inf[. This has two
> problematic areas: the years within the range [3850, 3900[ are ambiguous,
> and the years within the range [3950, 4000[ do not exist. (For those who
> have been taught The Other Way Of Expressing Sets, read [A, B) where I
> have written [A, B[ and (A, B] where I have written ]A, B].)

True. However, I was thinking that if the OP had some code which could
compile then this problem would surface...

TTFN

Paul
--
Sent from the heart of British Technology at its best - the all
new RiscStation R7500 - now running with the new 50ns upgrade
All opinions expressed are solely mine and do not represent any
other persons or companies.



Fri, 26 Mar 2004 03:57:41 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

Quote:

> I amm getting a lot of compiler errors which i have no idea how to
> fix. I am sending you my whole code and please help me fix my errors.
> Mostly those that say that else is not a valid statement and that i
> did not close the parentheses when i did.
> Thankyou.

I have cleaned this up so it is compilable and readable.  There are
no guarantees that it does anything useful.  First, here are a
summary of the changes (including the reformatting of comments, which
is an automatic outcome of my reformatting program):

5,10c5,7
< will
<    recieve input from certain measuring devices. Using the data from
< these
<    devices the program will both print out the data that the devices
< had
<    provided and give a detailed forecast. */
---

Quote:
>     will recieve input from certain measuring devices. Using the data
>     from these devices the program will both print out the data that the
>     devices had provided and give a detailed forecast. */

13,14c10,12
< #define MIN 1.0/60.0
< main()
---
Quote:
> #define MIN (1.0/60.0)

> int main()

17,18c15
< barp1,
<       barp2, wind1, wind2;
---
Quote:
>         barp1, barp2, wind1, wind2;

25,26c22,23
< /* This part of the program reads in all the values from the input and
<      assigns them to various integer names */
---
Quote:
>     /* This part of the program reads in all the values from the input
>        and assigns them to various integer names */

29c26
<     printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1, \
---
Quote:
>         printf("Current observation %d/%d/%d %d:%2.2d\n", month1, day1,

31c28,29
<   } else {
---
Quote:
>     }
>     else {

33,34c31
< year1 + 200\
<             0, hour1, minute1);
---
Quote:
>                year1 + 2000, hour1, minute1);

39,40c36,38
< bartend=
((1.0*barp1-barp2)/((1.0*hour1+(minute1*MIN))-(hour2+(minute2*MIN)))\
<            );
---
Quote:
>     bartend =
>         ((1.0 * barp1 - barp2) /
>          ((1.0 * hour1 + (minute1 * MIN)) - (hour2 + (minute2 * MIN))));

44,46c42,44
< barp1, barte\
<             nd);
<   } else if (bartend >=2) {
---
Quote:
>                barp1, bartend);
>     }
>     else if (bartend >= 2) {

48,61c46,58
< barp1,  \
<               bartend);
<   } else if (bartend <= -1 && bartend > -2) {
<          printf("Barometer: %d millibars, falling slowly (%f
< mb/hr)\n", barp1, \
<                 bartend);
<   } else if (bartend <= -2) {
<          printf("Barometer: %d millibars, falling rapidly (%f
< mb/hr)\n", barp1,\
<                   bartend);
<   } else if (bartend < 1 II bartend > -1) {
<          printf("Barometer: %d millibars, falling slowly (%f
< mb/hr)\n", barp1, \
<                 bartend);
---
Quote:
>                barp1, bartend);
>     }
>     else if (bartend <= -1 && bartend > -2) {
>         printf("Barometer: %d millibars, falling slowly (%f mb/hr)\n",
>                barp1, bartend);
>     }
>     else if (bartend <= -2) {
>         printf("Barometer: %d millibars, falling rapidly (%f mb/hr)\n",
>                barp1, bartend);
>     }
>     else if (bartend < 1 || bartend > -1) {
>         printf("Barometer: %d millibars, falling slowly (%f mb/hr)\n",
>                barp1, bartend);

64,65c61,62
< /* Checks the barometric tendency and prints it out with the current
<     observation's millibar reading. */
---
Quote:
>     /* Checks the barometric tendency and prints it out with the
>        current observation's millibar reading. */

68c65,66
<     case 1: printf("Wind direction: SW\n");
---
Quote:
>     case 1:
>         printf("Wind direction: SW\n");

70c68,69
<     case 2: printf("Wind direction: S\n");
---
Quote:
>     case 2:
>         printf("Wind direction: S\n");

72c71,72
<     case 3: printf("Wind direction: SE\n");
---
Quote:
>     case 3:
>         printf("Wind direction: SE\n");

74c74,75
<     case 4: printf("Wind direction: W\n");
---
Quote:
>     case 4:
>         printf("Wind direction: W\n");

76c77,78
<     case 5: printf("Wind direction: calm (no wind)\n");
---
Quote:
>     case 5:
>         printf("Wind direction: calm (no wind1)\n");

78c80,81
<     case 6: printf("Wind direction: E\n");
---
Quote:
>     case 6:
>         printf("Wind direction: E\n");

80c83,84
<     case 7: printf("Wind direction: NW\n");
---
Quote:
>     case 7:
>         printf("Wind direction: NW\n");

82c86,87
<     case 8: printf("Wind direction: N\n");
---
Quote:
>     case 8:
>         printf("Wind direction: N\n");

84c89,90
<     case 9: printf("Wind direction: NE\n");
---
Quote:
>     case 9:
>         printf("Wind direction: NE\n");

88,92c94,96
< /* This switch statement analyses the value inputted as integer wind1
< and
<    prints out the wind direction in words converting it from its
< number status
<    in the input */
---
Quote:
>     /* This switch statement analyses the value inputted as integer
>        wind1 and prints out the wind1 direction in words converting it
>        from its number status in the input */

96,100c100,104
< if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1019 && barp1
< <= 1023)\
<       && (bartend < 1 || bartend > -1)) {
<      printf("Fair with no significant temperature change for 1 to 2
< days\n");
---
Quote:
>     if ((wind1 == 1 || wind1 == 4 || wind1 == 7)
>         && (barp1 >= 1019 && barp1 <= 1023) && (bartend < 1
>                                                 || bartend > -1)) {
>         printf
>             ("Fair with no significant temperature change for 1 to 2 days\n");

102,104c106,109
<   }  else if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1019
< && barp1 \
<               <= 1023) && (bartend >=2) {
---
Quote:
>     }
>     else if ((wind1 == 1 || wind1 == 4 || wind1 == 7)
>              && (barp1 >= 1019 && barp1 <= 1023)
>              && bartend >= 2) {

107,111c112,117
<   }  else if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1023)
< &&      \
<              (bartend < 1 || bartend > -1)) {
<      printf("Fair with no significant temperature change for 1 to 2
< days\n");
---
Quote:
>     }
>     else if ((wind1 == 1 || wind1 == 4 || wind1 == 7)
>              && (barp1 >= 1023)
>              && (bartend < 1 || bartend > -1)) {
>         printf
>             ("Fair with no significant temperature change for 1 to 2 days\n");

113,115c119,122
<   }  else if ((wind == 1 || wind == 4 || wind == 7) && (barp1 >= 1023)
< &&      \
<              (bartend <= -1 && bartend > -2)) {
---
Quote:
>     }
>     else if ((wind1 == 1 || wind1 == 4 || wind1 == 7)
>              && (barp1 >= 1023)
>              && (bartend <= -1 && bartend > -2)) {

118,120c125,128
<   }  else if ((wind == 2 || wind == 3) && (barp1 >= 1019 && barp1 <=
< 1023) &&  \
<              (bartend <= -1 &&  bartend > -2)) {
---
Quote:
>     }
>     else if ((wind1 == 2 || wind1 == 3)
>              && (barp1 >= 1019 && barp1 <= 1023)
>              && (bartend <= -1 && bartend > -2)) {

123,125c131,134
<   }  else if ((wind == 2 || wind == 3) && (barp1 >= 1019 && barp1 <=
< 1023) &&  \
<              (bartend <= -2)) {
---
Quote:
>     }
>     else if ((wind1 == 2 || wind1 == 3)
>              && (barp1 >= 1019 && barp1 <= 1023)
>              && (bartend <= -2)) {

128,130c137,140
<   }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 >= 1019
< &&       \
<               barp1 <= 1023) && (bartend <= -1 &&  bartend > -2)) {
---
Quote:
>     }
>     else if ((wind1 == 3 || wind1 == 9 || wind1 == 6)
>              && (barp1 >= 1019 && barp1 <= 1023)
>              && (bartend <= -1 && bartend > -2)) {

133,135c143,146
<   }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 >= 1019
< &&       \
<              barp1 <= 1023) && (bartend <= -2)) {
---
Quote:
>     }
>     else if ((wind1 == 3 || wind1 == 9 || wind1 == 6)
>              && (barp1 >= 1019 && barp1 <= 1023)
>              && (bartend <= -2)) {

138,140c149,152
<   }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 <= 1016)
< &&      \
<              (bartend <= -1 &&  bartend > -2)) {
---
Quote:
>     }
>     else if ((wind1 == 3 || wind1 == 9 || wind1 == 6)
>              && (barp1 <= 1016)
>              && (bartend <= -1 && bartend > -2)) {

143,152c155,166
<   }  else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 <= 1016)
< &&      \
<              (bartend <= -2)) {{
<           if (month1 == 12 || month1 == 1 || month1 == 2)
<           printf("Rain and windy; clearing and colder within 36
< hours\n");
<           printf("We are happy to provide you with this forecast\n");
< }    else if ((wind == 3 || wind == 9 || wind == 6) && (barp1 <= 1016)
< &&    \
<                (bartend <= -2)) {
---
Quote:
>     }
>     else if ((wind1 == 3 || wind1 == 9 || wind1 == 6)
>              && (barp1 <= 1016)
>              && (bartend <= -2)) {
>         if (month1 == 12 || month1 == 1 || month1 == 2) {
>             printf
>                 ("Rain and windy; clearing and colder within 36 hours\n ");
>             printf("We are happy to provide you with this forecast\n");
>         }
>         else if ((wind1 == 3 || wind1 == 9 || wind1 == 6)
>                  && (barp1 <= 1016)
>                  && (bartend <= -2)) {

155,157c169,172
<   }}  else if ((wind == 1 || wind == 2) && (barp1 <= 1016) && (bartend
< >= 1 && \
<               bartend < 2)) {
---
Quote:
>         }
>     }
>     else if ((wind1 == 1 || wind1 == 2)
>              && (barp1 <= 1016) && (bartend >= 1 && bartend < 2)) {

161,168c176,184
<      else if ((wind == 2 || wind == 1) && (barp1 <= 1009) && (bartend
< <= -2)){{
<           if (month1 == 12 || month1 == 1 || month1 == 2)
< printf("Severe storm, clearing and colder within 24 hours\n");
<           printf("We are happy to provide you with this forecast\n");
<      }    else if ((wind == 2 || wind == 1) && (barp1 <= 1009) &&
< (bartend <=  \
<                  -2)) {
---
Quote:
>     else if ((wind1 == 2 || wind1 == 1)
>              && (barp1 <= 1009) && (bartend <= -2)) {
>         if (month1 == 12 || month1 == 1 || month1 == 2) {
>             printf
>                 ("Severe storm, clearing and colder within 24 hours\n");
>             printf("We are happy to provide you with this forecast\n");
>         }
>         else

...

read more »



Fri, 26 Mar 2004 05:38:35 GMT  
 Help on my C code, dont understand how to fix my compiler errors (PLEASE HELP)

Quote:

> Why are you beeing so mean to this poster?  Why take the time to respond if
> your intention is to belittle a novice?  

Mean?  You call that *mean*?  You should have been around here a
few years ago.  That was *nice*, compared to the way I used to
respond to people.  I've moderated a great deal in my old age.[1]

Quote:
> I feel that the purpose of this newsgroup is to help beginners who have
> read the faq and posted a sincere question.  If you don't treat people with
> respect they will shun this forum or respond with a troll or flame.

I treat people with respect... when I feel like they're making an
honest effort.  That program there looked to me like the guy
wasn't even trying.  It had things that were just *silly* in it.
Doubled braces?  Unbalanced parentheses?  Randomly strewn
backslashes?

Quote:
> I realize that it is annoying to answer the same questions over and over
> again, but I think that some regulars in this group should be more
> understanding.  Chris Torek's posts are never condescending and are always
> to the point.  I always learn something when I read them and often print
> them out.  This newsgroup would benefit vastly if people would treat
> posters as he does.

I'm no Chris Torek.  He's on some kind of higher level.  Maybe
I'll reach that point someday.  Until then, I can only hope to
help people with simple problems.

[1] That's sarcasm, yes.  I turned 23 on the 1st.  I've been
{*filter*} out here since I was, I dunno, 17 maybe? and in
clc.moderated longer than that.



Fri, 26 Mar 2004 11:43:12 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Compiler error CS 1595 - Help

2. Learning Linked Lists, Code Attached, My understanding of code attached, Please confirm understanding

3. Help in understanding the compiler error

4. Please help : cannot understand error mesg.

5. Please help fix code.

6. please help me fix my code

7. Can someone please help me fix this error?

8. Fatal Error C1001 Please help (FIXED!!!)

9. Please help me to fix this error

10. Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!Please help!!!!

11. some code i dont understand

12. code i dont understand

 

 
Powered by phpBB® Forum Software