Expected unqualified-id before string constant despite no string constants in the code and the file claims to not exist

Viewed 16

I'm writing a simple program for my CSC class and it says that there's an unexpected unqualified id before the string, despite there being no string constant. Also it says program file does not exist when I go to run it. I tried the search project thing and it doesn't appear in the program selection.

#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main() {
    cout<<"Enter the lengths for each side and then the unit they were measured in - >";
    double FirstSide,SecondSide,ThirdSide;
    cin>> FirstSide >> SecondSide >> ThirdSide ;
    cout<<fixed;
    double Perimeter = FirstSide+SecondSide+ThirdSide;
    double SemiP = Perimeter/2;
    double Area = sqrt((FirstSide*(SemiP-FirstSide)*(SemiP-SecondSide)*(SemiP-ThirdSide)));
    cout<<"The Triangle has a perimeter of "<<Perimeter<<" a semi-perimeter of "<<SemiP<<" and an Area of "<<Area<<"".""<<endl;
    return 0;
}

enter image description here

1 Answers

The error is in line 15 , 2 double quotes too much.

Replace your code with the following code :

#include<iostream>
    #include<cmath>
    #include<iomanip>

    using namespace std;

    int main() {
        cout<<"Enter the lengths for each side and then the unit they were measured in - >";
        double FirstSide,SecondSide,ThirdSide;
        cin>> FirstSide >> SecondSide >> ThirdSide ;
        cout<<fixed;
        double Perimeter = FirstSide+SecondSide+ThirdSide;
        double SemiP = Perimeter/2;
        double Area = sqrt((FirstSide*(SemiP-FirstSide)*(SemiP-SecondSide)*(SemiP-ThirdSide)));
        cout<<"The Triangle has a perimeter of "<<Perimeter<<" a semi-perimeter of "<<SemiP<<" and an Area of "<<Area<<"."<<endl;
        return 0;
    }
Related