Reputation: 65
I am getting the error "C++ requires a type specifier for all declarations" on my "const MAX = 10;" line.
Here is my code:
//A program that adds up the maximum of 10 numbers ( 1,2,3,4,5,6,7,8,9,10 )
#include <iostream>
#include <cmath>
using namespace std;
const MAX = 10; //the error is here!
int main()
{
int sum, num;
sum = 0;
num = 1;
do
{
sum = sum + num;
num++;
}
while (num <= MAX);
{
cout << "Sum = ";
}
return 0;
}
Upvotes: 3
Views: 14308
Reputation: 20631
As the error says, C++ requires a type specifier for the declaration. For instance, change const MAX = 10;
to const int MAX = 10;
.
Upvotes: 4