Question

Compute the average kids per family Note that the integers should be type cast to doubles #include Kiostream 2 using namespace std 4 int maino int numb idSAE 13 6 int numKids8 e 4; int numKidsc 55 int nunfamilies double 0.01 10 Your answer 11 Average kids per family: avgkids endl a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <iostream>
using namespace std;

int main() {
   int numkidsA=1;
   int numkidsB=4;
   int numkidsC=5;
   int numfamily=3;
   double averagekids=0.0;
averagekids=(double)   (numkidsA+numkidsB+numkidsC)/numfamily;
cout<<averagekids;
   return 0;
}

output:

3.33333

Add a comment
Know the answer?
Add Answer to:
Compute the average lids per family. #include <iostream> using namespace std; int main() {int numKids a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • what is the output for the following code? explain the steps. /*#include <iostream> using namespace std;...

    what is the output for the following code? explain the steps. /*#include <iostream> using namespace std; int f(int &i) { i = 10; return(5 * i); } int main() { int n = 5; f(n); cout << n << "\n"; return 0; } #include <iostream> using namespace std; int sub1(int n) { n--; return n; } int main() { int m = 10; for(int j = 0; j < 10; j++) m -= sub1(j); cout << m << "\n"; return...

  • What does this print to the screen? #include <iostream> using namespace std; int main() { int...

    What does this print to the screen? #include <iostream> using namespace std; int main() { int c = 5; int *p = &c; *p *= c; cout << *(++p); return 0; } I get 0 in Xcode, but it looks to me like it should be giving me the memory location. Please step me through the process.

  • in c++ #include <iostream> using namespace std; int main() int beta[7] = 3, 5); for (int...

    in c++ #include <iostream> using namespace std; int main() int beta[7] = 3, 5); for (int i = 2; i < 7; i++) beta[i] = 3 * i + 2; beta[i - 1] = beta[i - 1] + beta[i]; beta[i - 2) = betali - 2] + beta (i - 1]; for (int i = 0; i < 7; i++) cout << beta[i] << " "; cout << endl; return 0;

  • One dimensional array What this code print #include <iostream> using namespace std; int main () {...

    One dimensional array What this code print #include <iostream> using namespace std; int main () { const int SIZE = 7; int numbers [SIZE] = {1, 2, 4, 8): // Initialize first 4 elements cout << “Here are the contents of the array:\n"; for (int index = 0; index < SIZE: index++} cout << numbers[index] << “ “; cout << endl; return 0; }

  • What is the output of this program? #include<iostream> using namespace std; int main() { int x=4,...

    What is the output of this program? #include<iostream> using namespace std; int main() { int x=4, y=4, z=4; x += 2; y = z++; z = ++x + y; cout<<x<<" "<<y<<" "<<z<<endl; return 0; } Group of answer choices 4 4 4 7 4 11 7 5 12 6 5 11

  • #include<iostream> #include<cstdlib> using namespace std; int main() {     // create array of size 20    ...

    #include<iostream> #include<cstdlib> using namespace std; int main() {     // create array of size 20     int arr[20];         int i;         cout<<"scores : ";     for( i = 0 ; i < 20 ; i++ )     {         // generate a random number i range 70 - 100 an add it to arr         arr[i] = rand() % 31 + 70;                 cout<<arr[i]<<" ";     }         // store the total score     int total = 0;...

  • #include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be...

    #include <iostream> #include <chrono> using namespace std; double improvedPow(double x, int y) { // To be implemented by you } int main() { cout << "To calculate x^y ..." << endl; double x; int y; cout << "Please enter x: "; cin >> x; cout << "Please enter y: "; cin >> y; if(x == 0) { if (y > 0) cout << 0 << endl; else cout << "x^y is not defined" <<endl; } else { cout << improvedPow(x,y)...

  • Consider the following C++ program: #include <iostream> #include <cstdlib> using namespace std; int main int n...

    Consider the following C++ program: #include <iostream> #include <cstdlib> using namespace std; int main int n =0; int i = 0; cout << "Please enter a strictly positive number:"; cin >> n if (n <= 0) exit(EXIT_FAILURE) while (n > 1) n-n/2; i << endl; cout"Output:" return 0; Answer the following questions: What is the output of the program for each of the following values of n: -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9? What does...

  • #include <iostream> uisng  namespace std; int main() {             cout<<"Enter your three test scores and I...

    #include <iostream> uisng  namespace std; int main() {             cout<<"Enter your three test scores and I will ";                  <<" average them: ";             int score1, score2, score3,             cin>>score1>>score2>>score3;             double average;             average = (score1 + score2 + score3) / 3.0;             if (average = 100);                         perfectScore = true; // set the flag variable             cout<<"Your average is "<<average <<endl;             bool perfectScore;             if (perfectScore);             {                         cout<<"Congratulations!\n";                         cout<<"That's a perfect score.\n";                        ...

  • What does this print to the screen? #include <iostream> using namespace std; int main () {...

    What does this print to the screen? #include <iostream> using namespace std; int main () { int *a; a = new int[2]; for(int i = 0; i < 2; i++) *(a + i) = i; for(int i = 0; i < 2; i++) cout << a[i] << " "; delete [] a; return 0; } I'm getting 0 1 Please step me through the process.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT