Thread: Help with modules

  1. #1
    Registered User
    Join Date
    Oct 2012

    Help with modules

    I've just started to write this program to learn modularity, but I already know I'm going to have trouble writing it. I'm asked to write a function named totamt() that accepts four integer arguments named quarters, dimes, nickels, and pennies in a piggybank. The function should determine and return the dollar value of the number of quarters, dimes, nickels, and pennies past through it.

    In the program so far I have:

    #include <stdio.h>
    int main()
    void totamt(int,int,int,int);//the function prototype
    int quarters,dimes,nickels,pennies;//declares values as integers
    printf("Enter the number of quarters: \n");
    printf("Enter the number of dimes: \n");
    printf("Enter the number of nickels: \n");
    printf("Enter the number of pennies: \n");

    I'm currently rereading the chapter Modularity Using Functions: Part 1 so I'll be able to comprehend the material better to write this program. Also, for this program will I need to use function stubs.
    Attached Files Attached Files

  2. #2
    SAMARAS std10093's Avatar
    Join Date
    Jan 2011
    Nice, France
    Please try to wrap your code into code tags like this

    [key]your Code goes here[/key] Replace key with code in order this to work

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    A development process
    Shows you how to start with an idea in main, then modularise it so specific items of functionality (like say, readUserInput) are in separate functions (and in larger projects, separate files).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Join Date
    Oct 2007
    Inside my computer
    This looks more like C to me than C++. Tell me, which language is it that you truly are trying to learn (or want to learn)?
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help with fixing modules
    By 116soulja in forum C Programming
    Replies: 10
    Last Post: 01-16-2010, 12:26 AM
  2. modules in C++
    By jamort in forum C++ Programming
    Replies: 1
    Last Post: 06-03-2009, 02:07 AM
  3. Modules
    By Hakim in forum C++ Programming
    Replies: 2
    Last Post: 04-22-2006, 04:53 PM
  4. Modules
    By tim545666 in forum C++ Programming
    Replies: 0
    Last Post: 04-10-2002, 11:44 PM
  5. Modules
    By Garfield in forum C Programming
    Replies: 4
    Last Post: 09-30-2001, 10:23 AM