Thread: working with functions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    76

    working with functions

    Hello everyone,

    I am working with functions now and tryin to understand them.

    I have been practicing different ways for using them.

    such as below:
    Code:
    int greetings();                       // this is a prototype 
     
    int age();
    
    int main()
    {
    
    	int greetings();                   // this is a function header
    	{                                  // start of function body
    
            char name[20];
    		cout << "Please enter your name?  ";
    		cin >> name;
    		cout << "Hello "<< name <<"\n";
    
    	
    	}                                  //end of function body
    
    
     cout <<"Enter your age? ";
    
    
    	    int age();            
    		
    		{                    
        	int age;
    
    	    cin >> age;
    		cout << "You are  " << age << " years old\n\n";
    
    		} 
    /* Next I would like to use my greetins function again in        
        my program: */
    
      int greetings();    // :here                    
    
    
    	return 0;
    }

    What I would like to learn next is how to use the same functions over in the program.

    I would normally use a loop to repeat this code but I want to know how to reuse the functions in the program.
    Last edited by robasc; 12-26-2005 at 10:53 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 7
    Last Post: 11-17-2008, 01:00 PM
  2. Static functions.... why?
    By patricio2626 in forum C++ Programming
    Replies: 4
    Last Post: 04-02-2007, 08:06 PM
  3. Static member functions more efficient?
    By drrngrvy in forum C++ Programming
    Replies: 6
    Last Post: 06-16-2006, 07:07 AM
  4. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  5. Functions are not working
    By founder247184 in forum C++ Programming
    Replies: 0
    Last Post: 11-29-2002, 04:00 PM