fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int a, b, c, sum;
  5. float avg;
  6.  
  7. // Prompt user for input
  8. printf("Enter three numbers: ");
  9. scanf("%d %d %d", &a, &b, &c);
  10.  
  11. // Calculate sum and average
  12. sum = a + b + c;
  13. avg = sum / 3.0; // Ensure float division
  14.  
  15. // Display the average with 2 decimal places
  16. printf("The average is equal to: %.2f\n", avg);
  17.  
  18. return 0; // Indicate successful termination
  19. }
  20.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Enter three numbers: The average is equal to: 232068576.00