donmike25

inlab(1)2013

Jul 9th, 2013
288
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. #include <stdio.h>
  2. int main()
  3. {
  4.  
  5. int oddcount = 0;
  6. int evencount = 0;
  7. int x, min = 999;
  8.  
  9.  
  10. do
  11. {
  12.     printf("Enter an integer (0 to end):");
  13.     scanf("%d",&x);
  14.  
  15.  
  16.  
  17.     if( x != 0) {
  18.        
  19.         if (x < min){
  20.             min=x;
  21.            
  22.             }
  23.         if (x%2==0){
  24.             evencount++;
  25.             }
  26.        
  27.         else{
  28.             oddcount++;
  29.             }
  30.     }
  31.  
  32.  
  33.    
  34. }
  35. while (x!=0);
  36.  
  37.        
  38.        
  39.         if(oddcount > 0){
  40.             printf("The count of odd num is:%d\n",oddcount);
  41.         }
  42.         else{
  43.             printf("The count of odd num is: 0\n");
  44.         }
  45.         if(evencount > 0){
  46.            
  47.             printf("The count of even num is:%d\n",evencount);
  48.         }
  49.         else{
  50.             printf("The count of even num is: 0\n");
  51.         }
  52.         if(min == 999){
  53.             printf("Min value: None\n");
  54.         }
  55.         else{
  56.             printf("Min value: %d\n", min);
  57.         }
  58.  
  59.        
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment