Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

how to use string in if else statement c++

const string YES = "yes";
const string NO = "no";
const double FRAME_COST = 45.0;


int main()
{
    string input;
    double frames;
    cout << "Hello World" << endl; 
    cin >> input;

    if(input == YES)
    {
        cout << "How many?" << endl;
        cin >> frames;
        frames = frames * FRAME_COST;
        cout << frames << endl;
   }

   return 0;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #string #statement
ADD COMMENT
Topic
Name
7+2 =