Advertisement
Aminpro

[ECP 1016]Tutorial 5 Question 4

Jul 15th, 2012
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.50 KB | None | 0 0
  1. //https://www.facebook.com/AminproPastebin
  2.  
  3. #include <stdio.h>
  4.  
  5. int main()
  6. {
  7.     float x=0;
  8.     float total;
  9.     int count=1;
  10.     int avgcount=0;
  11.     int numint =0;
  12.     printf("Please enter the number of intergers");
  13.     scanf("%d", &numint);
  14.     while(count<=numint){
  15.     printf("Enter the %d's interger", count);
  16.     scanf("%f", &x);
  17.         if(x>0){
  18.         total = x + total;
  19.         avgcount ++;
  20.         count ++;
  21. }
  22.         else{count++;}
  23.    
  24.        
  25. }
  26.     total = total/avgcount;
  27.     printf("The average is %.2f\n", total);
  28.    
  29.  
  30.  
  31.  
  32. return 0;
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement