Eng-Mohamed-Essam

Untitled

Jul 30th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <cs50.h>
  3. #include <math.h>
  4. int main()
  5. {
  6.     float c;
  7.     int s = 0, z = 0, d = 0, e = 0, x = 0, f = 0, cc = 0;
  8.     do
  9.     {
  10.         c = get_float("Change:");
  11.     }
  12.     while (c < 0);
  13.     c = c * 100;
  14.     cc = c / 1;
  15.  
  16.     s = c / 25; // 1
  17.     z = cc % 25;
  18.    
  19.     d = z / 10 ; // 2
  20.     e = z % 10;
  21.  
  22.     x = e / 5; // 3
  23.     f = e % 5;
  24.     printf("I have %i Coins\n", s + d + x + f);
  25.     return 0;  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment