How To Find Mobile Numbers In Bangalore?

Using a For loop you must find the average of all the even numbers and all the odd integers between 0 and 100?

  • Using a For loop you must find the average of all the even numbers and all the odd integers between 0 and 100 (including 100). You will need variables to keep track of the current sum of the odd numbers, current sum of the even numbers, number of odd numbers and number of even numbers so that you can calculate and report to the user the average of the odd numbers and average of the even numbers. You must use Modulus to decide whether a number is even or odd.

  • Answer:

    Using a for loop.. repeatedly ask other people to do your homework. Using an if statement.. determine if having somebody else do your homework for you helps you learn. Write the code, and if you have specific problems ask about them. Don't be so lazy.

Tony at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

something like this (this is a java example but you'll get the jist of it). A for lus that goes from 0 to 100, and every count it'll check if the teller is even or not (% is modulus sign, to get the rest value of a devide (2 / 2 = 0 for example). It'll increase the tellers by one and increase the sum with the value of i, then devide the sum by count and you have your avarage. double oddSum = 0, evenSum = 0, oddCount = 0, evenCount = 0; for(int i; i < 101; i++){ if(i % 2 == 0){ evenSum += i; evenCount++; } else{ oddSum += i; oddCount ++; } double avgEven = evenSum / evenCount; double avgOdd = oddSum / oddCount; }

// number of odds int nbOdd = 0; // number of evens int nbEven = 0; // running total of odds int totalOdd = 0; // running total of evens int totalEven = 0; // start loop for(i=1;i<101;i++) { // test using modulus if (i % 2 == 0) { // even nbEven++; totalEven = totalEven + i; }else { // odd nbOdd++; totalOdd = totalOdd + i; } } // end loop // compute averages double avgOdd = totalOdd / nbOdd; double avgEven = totalEven / nbEven;

k=1; l=1; a=0; b=0; for(i=0;i<=100;i++) { if(i%2==0) { a=a+i; even_av=a/k k++; } else { b=b+i; odd_av=b/l l++; } }

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.