online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
#include <stdio.h> #include "Car.h" int main () { Car myCar = InitCar (); int userYear; int userPrice; int userCurrentYear; scanf ("%d", &userYear); scanf ("%d", &userPrice); scanf ("%d", &userCurrentYear); myCar = SetModelYear (userYear, myCar); myCar = SetPurchasePrice (userPrice, myCar); myCar = CalcCurrentValue (userCurrentYear, myCar); PrintInfo (myCar); return 0; }
#ifndef CAR_H_ #define CAR_H_ typedef struct Car_struct { int modelYear; int purchasePrice; int currentValue; } Car; Car InitCar(); Car SetModelYear(int userYear, Car); void SetPurchasePrice(int price, Car car); int GetPurchasePrice(const Car *car); Car CalcCurrentValue(int currentYear, Car car); void PrintInfo(const Car *car); #endif
#include <stdio.h> #include <math.h> #include "Car.h" Car InitCar() { Car car; car.modelYear = 2020; car.purchasePrice = 0; car.currentValue = 0; return car; } Car SetModelYear(int userYear, Car car) { car.modelYear = userYear; return car; } void SetPurchasePrice(int price, Car) { car->purchasePrice = price; } int GetPurchasePrice(const Car *car) { return car->pruchasePrice; } Car CalcCurrentValue(int currentYear, Car car) { double depreciationRate = 0.15; int carAge = currentYear - car.modelYear; int depreciation = carAge * 3000; //Car deprecation formula car.currentValue = (int) round(car.purchasePrice * pow((1.0 - depreciationRate), carAge)); return car; } void PrintInfo(const Car *car) { printf("Car's information:\n"); printf(" Model year: %d\n", car->modelYear); printf(" Purchase price: %d\n", car->purchasePrice); printf(" Current value: %d\n", car->currentValue); }

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue