Pages

Tuesday, March 20, 2018

Bitcoin Trading Profit Loss


Bitcoin Trading Profit Loss Calculation.

Following C Program will help you to calculate your Bitcoin Trading  profit or loss.

#include<stdio.h>

int main(){

   float current_btc_price, avg_cost;
   float total_btc, profitloss;

   printf("Enter Your Total Bitcoin: ");
   scanf("%f",&total_btc);

   printf("Enter Current Bitcoin Price: ");
   scanf("%f",&current_btc_price);

   printf("Your Average Bitcoin Purchase Price: ");
   scanf("%f",&avg_cost);

   //profitloss = (current_btc_price - averagecost) x total_btc

   profitloss = (current_btc_price - avg_cost) * total_btc;

   if(profitloss > 0)
printf("Bitcoin Trading Profit is: %0.2f",profitloss);
   else
printf("Bitcoin Trading Loss is: %0.2f",profitloss);

   return 0;
}


Output of program:

Enter Your Total Bitcoin: 2
Enter Current Bitcoin Price: 250000
Your Average Bitcoin Purchase Price: 150000
Bitcoin Trading Profit is: 200000.00


No comments:

Post a Comment