Thread: Void Functions Help

  1. #1
    Registered User
    Join Date
    May 2005

    Void Functions Help

    I need a little help - I am working on the 3 programs below and I am not sure how to use or write void functions. Can someone give me an example or some instructions? I don't want the entire program for the three below, just some help. Please!!

    1. Write a program that reads in two integers from the keyboard and displays their sum. The reading function should read in both integers at the same time. Both the reading and displaying functions should be separate void functions.

    2. Write a void function called swap that takes two integer parameters and swaps their contents. Write another swap function that takes two double arguments. Write a short main function that calls both swap functions and demonstrates that the contents have been swapped. Cout statements should appear in function main.

    3. Rewrite your answer for question 2 using a single swap template instead of two swap functions. If done correctly, the main () function should not change.

  2. #2
    Registered User
    Join Date
    Jan 2005
    A void function is just a function that doesn't return anything. The point seems to be to use some other mechanism for returning a value from a function. Think back to what you've read or been taught recently on ways to get data out of functions. The answer either begins with an 'r' or a 'p'.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. saying hello and 1st question
    By darksys in forum C Programming
    Replies: 12
    Last Post: 10-31-2008, 02:58 PM
  2. Interpreter.c
    By moussa in forum C Programming
    Replies: 4
    Last Post: 05-28-2008, 05:59 PM
  3. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM