Expected Primary-Expression before "char"

Hello, all!

I'm currently writing a program for my C++ class... Unfortunately, I have run into an issue that I can't seem to solve. I'm sure it's an easy issue that I am just not seeing, so I thought I'd throw it up here. I'll continue to try to figure it out while waiting for a reply.

(I am using Dev-C++) When I try to compile it, it gives me:
line 15: expected primary-expression before "char"
line 15: expected ';' before "char"
line 23: expected primary-expression before "continue"
line 23: expected ')' before "continue"
line 23: expected ';' before '==' token
line 23: expected primary-expression before "continue" (yes, it gave this one twice)
line 23: expected ';' before "continue"


Anyway, here it is:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
///////////////////////////////////////////////////////////
//Description: A program to calculate the speed of sound.
//Accept user input of two air tempuratures, then display
//the velocity of sound at that air tempurature.
//
//Formula to find speed:
// velocity = 331.3 + 0.61 * currentTemp
////////////////////////////////////////////////////////////

#include <iostream>
using namespace std;

int main()
{
    char continue = 'y'; //do it again?
    int temp1; //starting tempurature
    int temp2; //ending tempurature
    int currentTemp; //current tempurature being calculated
    double velocity; //velocity of sound at given tempurature


    while (continue == 'y' || continue == 'Y')
    {
          cout << "Enter the starting tempurature, in Celsius (Must use whole numbers): ";
          cin >> temp1;
          cout << "\n\nEnter the ending tempurature, in Celsius (Must use whole numbers): ";
          cin >> temp2;
          system("cls");
          if (temp1 < temp2)
          {
               for (currentTemp = temp1; currentTemp <= temp2; currentTemp++)
               {
                   velocity = 331.3 + 0.61 * currentTemp;
                   cout << "At " << currentTemp << " degrees Celsuis the velocity of sound is " << velocity << "\n";
               }
          }
          else if (temp1 > temp2)
          {
               for (currentTemp = temp1; currentTemp >= temp2; currentTemp--)
               {
                   velocity = 331.3 + 0.61 * currentTemp;
                   cout << "At " << currentTemp << " degrees Celsuis the velocity of sound is " << velocity << "\n";
               }
          }
          else
          {
              velocity = 331.3 + 0.61 * temp1;
              cout << "You entered the same value for both. Only one answer will be given.\n\nAt " << currentTemp << " degrees Celsuis the velocity of sound is " << velocity << "\n";
          }
          cout << "\n\n\nWould you like to do this again? (y/n): ";
          cin >> continue;
    }
    system("pause");
    return 0;
}
Last edited on
'continue' is a reserved keyword.
Ah! Thank you for the quick reply... I need to print out a list of these reserved keywords, and at least familiarize myself with them.

Thanks again! That solved it :)
Topic archived. No new replies allowed.