Advertisement
Lisaveta777

Short artishok

Aug 23rd, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.10 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. //why line 47 get duplicated? how to fix it?
  5. int main()
  6. {
  7.      char ch;
  8.      float a,b,c,temp;//
  9.      a = b = c = temp = 0.0;
  10.  
  11.      printf("artishoks a\t\nbeetroot b\t");
  12.      printf("carrots c\t\nquit q\n");
  13.    
  14.      scanf("%c",&ch);
  15.      //scanf("%*[\n]");
  16.      while( ch!='q' )
  17.      {
  18.         switch(ch)
  19.         {
  20.         case 'a':
  21.             {
  22.                 printf("How much of artishoks do you want?\n");
  23.                 scanf("%f",&temp);
  24.                 a+=temp;
  25.             }
  26.             break;
  27.         case 'b':
  28.             {
  29.                 printf("How much of beetroot do you want?\n");
  30.                 scanf("%f",&temp);
  31.                 b+=temp;
  32.             }
  33.             break;
  34.         case 'c':
  35.             {
  36.                 printf("How much of carrots do you want?\n");
  37.                 scanf("%f",&temp);
  38.                 c+=temp;
  39.             }
  40.             break;
  41.  
  42.         }//end of switch
  43.         printf("chose a,b,c,or q now\n");
  44.  
  45.         scanf("%c",&ch);
  46.  
  47.      }//end of while
  48.  
  49.      return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement