can anyone help me with this code?
weight is 45 kg and if i at mar, my weight will be “weight * 37.83 / 100 = 17.0235” but my code ouput is -3.87569e+08 kg
#include <iostream>
int main() {
int weight;
float weightmar = weight * 37.83 / 100;
std::cout << "ur weight is: \n";
std::cin >> weight;
std::cout << "ur weight at mar is: " << weightmar << " kg" << std::endl;
}
Then, you prompt the user for input and assign it to weight. But, your calculation for weightmar has already been performed, so this input value doesn’t make a difference.
Instead you should consider re-arranging your code so that you get and assign the user input to weight first and then perform the calculation for weightmar.