Start New Discussion within our Software Development Community

i cant figure out why this outputs the wrong number
when i say the length and width is 1 it outputs 2293544. and i dont know if its reading the 2 numbers i put in for length and width

i use the magic formula and still does it

case 'B':;
case 'b':;
cout << " You have choosen B. rectangle." ;
cout << " please enter the length and width of the rug.\n" << endl;
cin >> length, width;

cout << " The total cost will be " << areaR << endl;
            areaR= (length * width);
            cin >> areaR;
            cin >> areaR;

>cin >> length, width;
This doesn't do what you think. A comma is inapproriate, it should be another >> operator:

cin>> length >> width;

>cout << " The total cost will be " << areaR << endl;
>areaR= (length * width);
>cin >> areaR;
>cin >> areaR;

This is nonsensical. The ordering seems goofy. You print areaR before assigning it a suitable value, then fill it with user input twice in a row?

This question has already been answered. Start a new discussion instead.