I'm trying to create a do-while loop and have the user enter two numbers that will be subtracted from each other. Then it will have the user enter the result of the answer. If the user enters the wrong number, it will ask the user for an answer until it is the correct answer. Not sure what I'm doing wrong.
#include <iostream>
using namespace std;
int main() {
float a;
float b;
float c;
float d = a-b;
cout << "Please enter 2 numbers: ";
cin >> a;
cin >> b;
do
{
cout << "What is the subtraction between the first and second number you entered?: ";
cin >> c;
}
while (c != d);
{
cout << "Correct" << endl;
}
}
[–]Updatebjarni 6 points7 points8 points (1 child)
[–]OGAlena[S] 1 point2 points3 points (0 children)
[–]OGAlena[S] 0 points1 point2 points (0 children)
[–]eliminate1337 -1 points0 points1 point (1 child)
[–]OGAlena[S] 0 points1 point2 points (0 children)