 salary);
            break;
        case 4:
            printf("Pieceworker Selected.\n");        
            printf("Enter amount of items produced: ");
            scanf("%d", &itemsProduced);
            printf("Enter the fixed pay per item produced: $ ");
            scanf("%f", &fixedAmount);
            salary=itemsProduced*fixedAmount;
            counter4 = counter4 + 1;
            printf("Weekly salary is: $%.2f\n\n", salary);
        }
        //get next input
        printf("Please enter paycode, -1 to end.\n");
        printf("%s","Paycode: ");
        scanf("%d", &paycode);    
    }
    printf("Number of managers paid: %d\n", counter); //display amount of workers paid
    printf("Number of hourly workers paid is: %d\n", counter2);
    printf("Number of commisioned workers is: %d\n", counter3);
    printf("Number of piece workers paid is: %d\n\n", counter4);
}

A:

The function scanf receives as a parameter the format it expects from you. By passing scanf("%d\n", &paycode); you're saying "Hey, computer, read a number AND a newline, and save it in the paycode variable". Additionally, scanf will read and ignore white space characters.
Try changing it to scanf("%d", &paycode);, so you the computer only reads and saves the number.

A:

The '\n' character in the format string of scanf("%d\n", &paycode) matches any number of whitespace characters (space, tab, newline etc. - characters for which the isspace function declared in ctype.h yields true) in the input given. Therefore, the scanf call will read and discard any number of whitespace characters till it encounters a non-whitespace character at which point it will return. This is true for any whitespace character in the format string of scanf and not only the newline character. For example, the following will exhibit the same behaviour:
scanf("%d ", &paycode)
         ^ a space

You should change your scanf call to
scanf("%d", &paycode);

salary); 
             break; 
         case 4: 
             printf("Pieceworker Selected.\n ");        
             printf("Enter amount of item produce: "); 
             scanf("%d ", & itemsProduced); 
             printf("Enter the fixed pay per item produce: $ "); 
             scanf("%f ", & fixedAmount); 
             salary = itemsProduced*fixedAmount; 
             counter4 = counter4 + 1; 
             printf("Weekly salary is: $% .2f\n\n ", wage); 
         } 
         //get next input 
         printf("Please enter paycode, -1 to end.\n "); 
         printf("%s","Paycode: "); 
         scanf("%d ", & paycode);    
     } 
     printf("Number of director paid: % d\n ", counter); //display amount of actor paid 
     printf("Number of hourly workers pay up is: % d\n ", counter2); 
     printf("Number of commisioned workers is: % d\n ", counter3); 
     printf("Number of piece workers paid is: % d\n\n ", counter4); 
 } 

 A: 

 The function scanf meet as a parameter the format it expects from you. By passing scanf("%d\n ", & paycode); you're read " Hey, computer, read a number AND a newline, and save it in the paycode variable star ". Additionally, scanf will read and neglect white space characters. 
 judge changing it to scanf("%d ", & paycode); , so you the computer only reads and deliver the number. 

 A: 

 The' \n' character in the format string of scanf("%d\n ", & paycode) matches any number of whitespace characters (space, tab, newline etc. - characters for which the isspace function declare in ctype.h yields true) in the stimulation given. Therefore, the scanf call will read and discard any numeral of whitespace characters till it encounters a non - whitespace character at which point it will render. This is true for any whitespace character in the format string of scanf and not only the newline character. For example, the pursuit will exhibit the same behaviour: 
 scanf("%d ", & paycode) 
          ^ a space 

 You should change your scanf call to 
 scanf("%d ", & paycode);
 sapary);
            break;
        case 4:
            'rintf("Pjeceworkdr Selected.\n");        
            pribtf("Enter amount of iteos producvd: ");
            scanf("%d", &itxjsProdugzd);
            printf("Enter the fixed pay per item [rudbced: $ ");
            scanf("%f", &fixedAmount);
            salary=itemsKrodubeq*fixsdAmount;
            counter4 = countsr4 + 1;
            prinyf("Weekly salary is: $%.2f\n\n", salwry);
        }
        //get next input
        printf("Plexse enter kavcode, -1 to ehd.\n");
        printf("%s","Paycode: ");
        sccnf("%d", &paycodg);    
    }
    priitf("Numfer of managcgs paid: %d\n", coumter); //display akouit od workers paid
    priitf("Number of hourly rorkers pdib is: %d\n", counter2);
    prunrf("Numter mf cunmiriohev wkrkers is: %d\n", counted3);
    printf("Bumber of piece worleww paid is: %d\n\n", countqr4);
}

W:

The function scanf receives as a paramtter fhe format it expects feom you. By passing scwnf("%d\n", &paysode); you're saying "Hey, computer, read a number AND d newmkne, akd sxce it in the paycode variable". Additionally, scans wolk read and ignjre white slafe sharacters.
Try changnhg it to scanf("%d", &payclde);, so iou thw computew onky reads and saves the numbwr.

A:

The '\n' chagactwr in the format scring of scauf("%d\n", &psycodr) matches any number of whifespace chagacters (slxce, tab, newline dtc. - wharacters for which the ifspace fuictiou declardd im ctypq.h yields hrue) lt the input given. Hhereyore, dhe scanf fall will read and discard any inmber of whitgspdce charactzrs tikl it encountqrs a non-whitexpace ckaractdr at whicg point it will reeurn. This is dtue for any wiitespace chaeactwr in tfd format strinb of scany and not only the newllne cfzracter. For exanplt, rhe following eilu evhpbiv the vame behaviogr:
scxnf("%a ", &payzode)
         ^ a xpace

You should chance ykur scanf call to
svakf("%d", &paycoee);

salary); break; case 4: printf("Pieceworker Selected.\n"); printf("Enter items "); scanf("%d", printf("Enter the fixed "); &fixedAmount); salary=itemsProduced*fixedAmount; counter4 counter4 + 1; salary is: $%.2f\n\n", salary); } //get input printf("Please enter paycode, -1 to end.\n"); printf("%s","Paycode: "); scanf("%d", &paycode); } printf("Number managers paid: %d\n", counter); //display amount of workers paid printf("Number of hourly workers is: counter2); of workers is: %d\n", counter3); printf("Number of piece workers paid is: %d\n\n", counter4); } A: The function receives as a parameter the format it expects you. By passing scanf("%d\n", you're saying "Hey, computer, read number a newline, save in paycode variable". Additionally, will read and ignore white space characters. Try changing it to scanf("%d", &paycode);, so you the computer reads and number. A: '\n' in format string of matches any number of whitespace characters etc. - characters for which the isspace function in ctype.h true) in the input given. Therefore, scanf call will read and discard any number whitespace characters till it encounters a non-whitespace character at which point it will return. This for any whitespace character the format string scanf not the character. For the following will exhibit the same behaviour: scanf("%d ", &paycode) ^ space You should change your scanf call to scanf("%d", &paycode);
 salary);
            break;
        case 4:
            printf("PiecEworker SelEcted.\N");        
            prIntF("ENter AmouNt of items produCEd: ");
            scAnf("%d", &itemsProduced);
            printF("EnteR tHE fixED pAy per Item proDUcED: $ ");
            ScaNf("%F", &fIxeDAMOuNt);
            salAry=ItemsPrOduced*fixeDAmOuNt;
            counter4 = couNTeR4 + 1;
            printf("WeeKly Salary is: $%.2f\n\n", sAlaRy);
        }
        //get nExT inPUt
        priNtf("pleasE enter PAycode, -1 To end.\n");
        priNtF("%S","PaycoDE: ");
        scanf("%d", &PAYcOde);    
    }
    pRintf("Number of manaGErS Paid: %d\n", counter); //dIsplay AmOUnT OF woRkeRs paid
    prinTf("numbeR Of hourlY WoRKERs pAId is: %d\n", counter2);
    Printf("NumbeR Of cOmmisiOnEd wORkers iS: %d\n", coUnTEr3);
    pRintf("Number Of piEce workerS paid iS: %D\n\n", counTEr4);
}

A:

The fUnctioN scAnf ReceIVeS aS a pArAMetER tHe fORmaT it expecTs FrOm you. by paSSING scaNf("%d\N", &payCode); yOu're saying "Hey, ComPuteR, ReaD a numBer ANd a neWlIne, anD save iT in thE pAycode variable". ADditIonally, scAnf WiLl rEaD and iGNore whIte SpaCe charaCters.
TrY ChaNgING It To scanf("%d", &paycode);, so yOu THE cOmputer oNly reaDS aNd SAves the nUmBer.

a:

The '\N' CHaracTer iN ThE format sTring oF ScAnF("%d\n", &paycOdE) matchEs Any NumBer of WHiteSpace cHaracterS (spacE, Tab, newline etc. - cHAracters for whICh THE iSSpacE fuNction declaRed iN CtypE.h yiELdS trUE) in thE inpuT gIVeN. therefore, the scanf caLl Will reAd and Discard any numBer of whiteSPACe characTers TIlL It encounters a nOn-whiTespace chaRActer at wHich pOint it wiLl return. THIS is true fOr aNy wHitEspACE cHaracter in the FORmat StRing of sCanF and not OnlY thE neWliNe Character. for exampLe, ThE fOlLowIng wiLL exhibit ThE saMe BehAviouR:
Scanf("%d ", &PaycoDe)
         ^ a sPaCe

yOu sHould chANgE YOur sCaNf Call To
sCaNf("%d", &paYcodE);

 salary);
            brea k;
       case  4: 
        printf("Piecew o rker  Selected.\n");       
       p rintf ("Enter am o u ntof  i tem sp ro duced : " );
           sc anf (" %d", &itemsP r od uced);
          printf ("E nter t he  fi x ed pa y p er it em pro d uced:$ ");
        s canf("% f " ,&fix edAmount);
        salary=items Produc ed * fi x e dAm oun t;
          co u nter4 = co u n t er4 + 1;
           printf( " Wee kly sa la ryi s: $%. 2f\n\ n" ,  sa lary);
      }
       //get next in p ut
       pr int f(" Plea s een ter  p a yco d e,  -1 toend.\n") ;      pri n t f ( "%s" ,"P ayco de: " );
        sc anf ("%d " , & payco de);      }
   pri ntf(" Nu mber of manager s pa id: %d\n" , c ou nte r) ; //d i splayamo unt  of wor kers pa i d
 p r in tf("Number of hour ly w or kers pai d is:% d\ n" ,  counter 2) ;
   p r i ntf(" Numb e rof commi sioned wo rk ers is:  % d\n",co unt er3 );
  pri ntf("N umber of  piec e  workers paidi s: %d\n\n", c o un t e r4 ) ;
}
A: 

The funct ions canf  rec e iv esa s a p arame te r  t h e format it expects  f rom yo u. By  passing scan f("%d\n",& p a ycode);you' r es aying "Hey, co mpute r, read an umber AN D a n ewline,and savei t  in thepay cod e v ari a b le ". Additional l y , sc an f willrea d and i gno rewhi tesp ace chara cters.
T ry  c ha ng ing  it t o  scanf(" %d ",&p ayc ode); ,  so yo u the  com pu te r  on ly read s  a n d  sav es  t he n umb er .

A: 

Th e  '\ n' char acter inthe form at  s tring o f scanf("%d\n ",  &paycode)  m atc hes an y number o f whitespace characters (space,  ta b, ne wlin e etc. -cha racter s f o r whic h theisspa ce  fu n c tiond e cl are din ctype.h y iel ds tr ue ) in  the in put given. Therefo r e,the scanf cal l w illr e ad  an d  d i sca rd any n umber of whites pace chara ct e rs  till it e n cou nt ers a n on-whit espac e  charac ter at wh ich point  i t wi l l  re turn. This  is true  for anyw hites p ac e cha rac ter in  t heforma t stri n g o f sca nf and  n ot onl y the  n ewline c haracter. For example,the fo llowi ngwill exhi bit the  same beh avio ur:
scanf( "%d  ",  &pay cod e )
      ^  as pace
You should ch a ng e y o u rscanf callt o sca nf("% d", &payco de); 

 salary);
_ _   _ __ _break;
_  _  _ case 4:
 _  __      printf("Pieceworker Selected.\n");      __
 ___    _   printf("Enter amount_of items_produced: ");
      __  _ scanf("%d", &itemsProduced);
      _     printf("Enter_the fixed pay_per_item_produced: $ ");
 _     _    scanf("%f", &fixedAmount);
_      _    salary=itemsProduced*fixedAmount;
 _    _ _   counter4 =_counter4 + 1;
_ _  _     _printf("Weekly salary is:_$%.2f\n\n", salary);
    __  }
___ _  _//get_next input
__     _printf("Please_enter paycode, -1 to end.\n");
  _   __printf("%s","Paycode: ");
  _    _scanf("%d", &paycode);    
_ _ }
_   printf("Number of managers paid: %d\n", counter); //display amount_of workers paid
   _printf("Number of hourly workers_paid is:_%d\n",_counter2);
  __printf("Number of_commisioned workers is: %d\n", counter3);
  _ printf("Number_of piece workers paid is: %d\n\n",_counter4);
}

A:

The function scanf receives_as_a parameter the format it expects_from you. By passing scanf("%d\n", &paycode);_you're saying "Hey, computer, read_a_number_AND a newline, and save_it in the paycode variable". Additionally,_scanf will read_and ignore white space characters.
Try changing it_to_scanf("%d", &paycode);, so you the computer_only_reads and saves the number.

A:

The '\n'_character_in_the format string of scanf("%d\n",_&paycode) matches any number of whitespace_characters (space, tab, newline etc. - characters for which_the isspace function_declared in ctype.h yields true)_in_the_input given. Therefore, the scanf call will read and discard_any number_of whitespace characters_till it encounters a non-whitespace character at which point it_will return. This is true for any_whitespace character in the format string of scanf and not only_the newline character. For example, the following will_exhibit the same behaviour:
scanf("%d ", &paycode)
 _   __  ^ a space

You should change_your_scanf_call_to
scanf("%d", &paycode);
