C examples for Data Type:float
Calculate the total revenue for the quarter and output it
#include <stdio.h> int main(void) { const float Revenue_Per_150 = 4.5f; unsigned short PC =11111110; // Stock sold in January unsigned short Memory =22222220; // Stock sold in February unsigned short Keyboard =33333330; // Stock sold in March float RevQuarter = 0.0f; // Sales for the quarter unsigned long QuarterSold = PC + Memory + Keyboard; // Calculate quarterly total printf("Stock sold in\n Jan: %d\n Feb: %d\n Mar: %d\n", PC, Memory, Keyboard); printf("Total stock sold in first quarter: %ld\n", QuarterSold); RevQuarter = QuarterSold / 150 * Revenue_Per_150; printf("Sales revenue this quarter is:$%.2f\n", RevQuarter); return 0;/*from w w w .ja v a2s .co m*/ }