Mega Code Archive

 
Categories / C Tutorial / Printf Scanf
 

Do calculation in printf

#include <stdio.h> main (){   float fRevenue, fCost;   fRevenue = 0;   fCost = 0;   printf("\nEnter total revenue: ");   scanf("%f", &fRevenue);   printf("\nEnter total cost: ");   scanf ("%f", &fCost);   printf("\nYour profit is $%.2f\n", fRevenue - fCost); } Enter total revenue: 1 Enter total cost: 2 Your profit is $-1.00