Advertisement
Aminpro

[ECP1016] In-Lab Assignment Trimester 2 2012 Number 2

Nov 28th, 2012
420
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.55 KB | None | 0 0
  1. //Feel free to optimize the code and send it to the Facebook page, I'll put your name on it...
  2. //https://www.facebook.com/AminproPastebin
  3. #include <stdio.h>
  4.  
  5. int main(){
  6.    
  7.     float num =0;
  8.     float max = 0;
  9.     float min = 0;
  10.     float avg = 0;
  11.     float total =0;
  12.    
  13.     printf("Enter temperature data for MON: ");
  14.     scanf("%f", &num);
  15.     if(num>max){
  16.         max = num;
  17.     }
  18.     else {
  19.         min = num;
  20.     }
  21.    
  22.     total = total + num;
  23.    
  24.    
  25.     printf("Enter temperature data for TUE: ");
  26.     scanf("%f", &num);
  27.     if(num>max){
  28.         max = num;
  29.     }
  30.     else {
  31.         min = num;
  32.     }
  33.    
  34.     total = total + num;
  35.    
  36.     printf("Enter temperature data for WED: ");
  37.     scanf("%f", &num);
  38.     if(num>max){
  39.         max = num;
  40.     }
  41.     else {
  42.         min = num;
  43.     }
  44.    
  45.     total = total + num;
  46.    
  47.     printf("Enter temperature data for THU: ");
  48.     scanf("%f", &num);
  49.     if(num>max){
  50.         max = num;
  51.     }
  52.     else {
  53.         min = num;
  54.     }
  55.    
  56.     total = total + num;
  57.    
  58.     printf("Enter temperature data for FRI: ");
  59.     scanf("%f", &num);
  60.     if(num>max){
  61.         max = num;
  62.     }
  63.     else {
  64.         min = num;
  65.     }
  66.    
  67.     total = total + num;
  68.    
  69.     printf("Enter temperature data for SAT: ");
  70.     scanf("%f", &num);
  71.     if(num>max){
  72.         max = num;
  73.     }
  74.     else {
  75.         min = num;
  76.     }
  77.    
  78.     total = total + num;
  79.    
  80.     printf("Enter temperature data for SUN: ");
  81.     scanf("%f", &num);
  82.     if(num>max){
  83.         max = num;
  84.     }
  85.     else {
  86.         min = num;
  87.     }
  88.    
  89.     total = total + num;
  90.    
  91.     avg = total/7.0;
  92.    
  93.     printf("\nThe minimum temperature is %.1f Celcius\n", min );
  94.     printf("The maximum temperature is %.1f Celcius\n", max);
  95.     printf("The average temperature for one week is %.1f Celcius", avg);
  96.    
  97.    
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement