I am trying to create an expression evaluator to expand my C++ knowledge. It is supposed to evaluate 5(x+7)-2. Here is the code:
#include <iostream>
#include <stdio.h>
#include <time.h>
using namespace std;
time_t now, later;
void sleep(int delay)
{
now=time(NULL);
later=now+delay;
while(now<=later)now=time(NULL);
}
int main(void){
//It finds an error here
int x, 5, 7, 2, total;
printf("Hello. This program will evaluate the expression 5(x+7)-2. \nEnter the value for x:");
//And here
total= 5(x+7)-2;
cin >> x;
cout << total << endl;
getchar();
return 0;}
I know it contains many errors; can someone tell me what I should do?
Thanks a lot!!!