0

What am I doing wrong

#include <iostream> using namespace std; int main() { int overhead = 1000000; int price = 3000000; int cost = 2000000; int sold; int income; int made = 10; int expenses = (cost*made) + overhead; income = sold*price; int profit = income-expenses; if (profit < 0) { cout << "loss" << endl; } else if (profit == 0){ cout << "broke even" << endl; } else { cout << "profit" << endl; } }

5th Apr 2020, 5:58 PM
Joshua Flynn
Joshua Flynn - avatar
3 ответов
+ 10
Value of variable sold is null that means you need to initialise it first than you can perform any operation with it.
5th Apr 2020, 6:04 PM
Ketan [#Be Happy 😄]
Ketan [#Be Happy 😄] - avatar
+ 4
in statement income = sold*price; you use uninitialized variable sold. set it in some value, for example: int sold = 5;
5th Apr 2020, 6:06 PM
andriy kan
andriy kan - avatar
0
Thank you everyone I got it to work
5th Apr 2020, 6:10 PM
Joshua Flynn
Joshua Flynn - avatar