<mosaic.cnfolio.com>
PROGRAM
  1. #include <stdio.h>
  2.                          //Evlove 1 pidgey = Needs 12 Candys = Gets 500 xp, double the xp with Lucky Egg = 1000xp gaind total.
  3.                          
  4. int experience(int,int); //This is different function that calculates the experienced gained and candys left
  5.  
  6. int main()      //This is the main function           
  7.                
  8. {
  9. int pidgeys; //This is the first interger.
  10. int candys;  //This is the second interger.
  11.  
  12. scanf("%d %d", &pidgeys, &candys); //This scans the input given. 1st pidgeys, 2nd candys.
  13. printf("You've got %d Pidgeys and %d Candys \n", pidgeys, candys); //prints the amount of pidgeys and candys you've got.
  14. experience(pidgeys,candys)//This calls the int experience(int,int) function.
  15.  
  16. }
  17.  
  18. int experience(int pidgey, int candy) //This functions is uses the pidgey and candy as its intergers.
  19. {
  20. int evolutions = 0;
  21. if(pidgey>0 && candy>=12) //If you have pidgeys more then 0 and candys more then 12 then the computer will do the formula given below.
  22. {
  23.  
  24.     while (pidgey > 0 && candy>= 12)
  25. {
  26.     candy = candy-12; //This formula subtracts the amount of candys by 12 until its no more subtractable.
  27.     pidgey--; //This formula subtracts the pidgeys by 1, when you use 12 candys to evolve. 24 candys used subtracts 2 pidgeys and so on.
  28.     evolutions++;} //This formula adds up the experienced gained and lucky egg experiece by the amount of pidgeys evolved. 1 pidgeys is 1000xp, 2 would be 2000.
  29.  
  30.     printf("Lucky Egg used, experience gained %d and %d candys left \n",evolutions*1000,candy); //This prints the experienced gained and candys left after doing the formula.
  31. }
  32.  
  33.     else if  (pidgey>0 && candy<12)printf("Not enough candys to evlove Pidgey"); //If the input of candy is below 12 this message will show up.
  34.         else if (pidgey<=0 && candy>0) printf("No Pidgey found"); //If the input is pidgey is below 0 this message will show up.
  35.             else if (pidgey == 0 && candy == 0) printf("YOU DONT HAVE ANYTHING");//If both input is 0 this message will show up.
  36.                 else if (pidgey < 0 || candy < 0) printf("ERROR, Check the input you've put in"); //If the input is wrong this will show up.
  37.                     else printf("ERROR, Make sure you've got right INPUT "); //This message will show up if there is a invalid wrong.
  38. }