I could not figure out the order of operations so created 2 more variables to do the math for (2b+c) and (d-e).

So is there a "better" way to write the math part of this or is how I did it correct?

This project has already been turned in, I just want to know for future problems as I'm sure the math will get more intense.

// MRW Lab_1b.cpp // Solve the equation a(2b+c)+(d-e) from user input #include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) { float vara, varb, varc, vard, vare, bcsum, desum, ans; //****heading**** printf("Please enter the values for variables to be used while solving a(2b+c)+(d-e)\n\n"); //****User input**** printf("a=");scanf(" %f",&vara); printf("b=");scanf(" %f",&varb); printf("c=");scanf(" %f",&varc); printf("d=");scanf(" %f",&vard); printf("e=");scanf(" %f",&vare); //****math**** bcsum = 2*varb+varc; desum = vard-vare; ans = vara *bcsum+desum; //****print final answer**** printf("The result for a(2b+c)+(d-e) is %f\n", ans ); return 0; }