Answer to Question #99406 in C++ for Caleb

Question #99406
#include <iostream>
using namespace std;

int main() {
int numKidsA;
int numKidsB;
int numKidsC;
int numFamilies;
double avgKids;

cin >> numKidsA;
cin >> numKidsB;
cin >> numKidsC;
cin >> numFamilies;

/* Your solution goes here */

cout << avgKids << endl;

return 0;
}

Compute the average kids per family. Note that the integers should be type cast to doubles.
1
Expert's answer
2019-12-13T11:32:05-0500

#include <iostream>

using namespace std;


int main() {

  int numKidsA;

  int numKidsB;

  int numKidsC;

  int numFamilies;

  double avgKids;


  cin >> numKidsA;

  cin >> numKidsB;

  cin >> numKidsC;

  cin >> numFamilies;


/* Your solution goes here */

  avgKids = (numKidsA + numKidsB + numKidsC) / (double)numFamilies;


  cout << avgKids << endl;


  return 0;

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS