dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: Java, C++
Expertise: Intermediate
Jul 19, 2001

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


Returning Multiple Values From A Method


Suppose you have some C++ code that you'd like to convert to the Java programming language. While doing the conversion, you come across the following code:
 
  void getStats(int data[], int& count,
  int& sum, int& mean) {
    count = 0;
    sum = 0;
    mean =  0;

    for (int i = 0; data[i] != -1; i++) {
      count++;
      sum += data[i];
    }

    if (count < 0) {
      mean = sum / count;
    }
  }

  int main() {
    int data[] = {10, 17, 39, -1};
    int count;
    int sum;
    int mean;

    getStats(data, count, sum, mean);

    printf(
Sudip Bhattacharya
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date