Count Money
eharetea

Counting the number of pennies and converting to other change in C.

Basic C program.

Date Created:Thursday March 01st, 2007 04:17 PM
Date Modified:Saturday August 02nd, 2008 01:58 PM


#include <stdio.h>

int count();

int main()
{
    int quarters;
    int dimes;
    int nickels;
    int pennies;
    

    printf("Enter in the number of pennies you have:\n");
    scanf("%d", &pennies);

    quarters count(25,pennies);
    pennies -= quarters*25;

    dimes count(10,pennies);
    pennies -= dimes*10;

    nickels count(5,pennies);
    pennies -= nickels*5;
        
    printf("%d quarters\n%d dimes\n%d nickels\n%d pennies"quartersdimesnickelspennies);

    return 0;
}

int count(int typeint cents)
{
    return cents/type;
}




Downloads:
Download: count.c 544 B

Please login or Click Here to register for downloads
Creative Commons License
Count Money by Dan Lynch
is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License
Based on a work at www.3daet.com
Permissions beyond the scope of this license may be available at http://www.3daet.com