Jump to content

View more

Image of the Day

Boxes as reward for our ranking mode. ヾ(☆▽☆)
#indiedev #gamedev #gameart #screenshotsaturday https://t.co/ALF1InmM7K
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

NEED HELP with my Function !!!

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 djacq   Members   

122
Like
Likes
Like

Posted 08 August 2001 - 06:52 AM

I need desperate help with solving a function problem that is stressing me out. How do you return an increment value from a function back into the main? Here''s a sample: #include #include void process_deposits (double, double, int, double); void process_deposits (double new_bal, double amount, int n_dep, double total_dep) { cout << "Enter the deposit amount : $ "; cin >> amount; new_bal += amount; ++n_dep; total_dep += amount; cout << "New balance : $ " << new_bal << " "; } int main (void) { while (tranx_type != ''Q'' && tranx_type != ''q'') { if (tranx_type == ''D'' || tranx_type == ''d'') { process_deposits (new_bal, amount, n_dep, total_dep); } else if (tranx_type == ''Q'' || tranx_type == ''q'') { cout << n_dep << " Deposits Totaling $ " << setw(8) << total_dep << "\n"; } }

#2 Clash Rocker   Members   

130
Like
Likes
Like

Posted 08 August 2001 - 07:11 AM

    
#include <iostream.h>

int f(void) //return type is int

{
int i;
cout<<"\nEnter integer: ";
cin>>i;

return ++i; //return value to calling function

}

int main(void)
{
cout<<f()<<endl; //Output 2


int i = f(); //i will become 2

cout<<i<<endl; //Output 2 also


return 0;
}

HTH



Edited by - Clash Rocker on August 8, 2001 2:14:27 PM




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.