1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ahat [919]
2 years ago
5

You are working for the census bureau and you need to write a program in C to do the following: a) count the number of people in

each of the following age groups: 0 - 18 infant, 18 - 29 young, 29 - 50 middle aged, 50 - 69 old, 69 - and older, really old. Report the number of people in each age group. (use some random data for test). b) they need some statistics regarding the distribution of ages. Write a program to read in a number of ages. Compute the average age (mean) and the mode i.e. the age that occurs most frequently (be careful, some of the ages might be the same). Ages should be read in as integers, the average should be a real number. Calculate also the standard deviation using the formula:
Computers and Technology
1 answer:
valina [46]2 years ago
8 0

Answer:

See explaination

Explanation:

#include<iostream>

#include<stdio.h>

#include<conio.h>

#include<math.h>

using namespace std;

void main()

{

int RandomData[]={10,5,20,45,20,66,25,31,20,70}; //Random Data

int infant=0,young=0,middle=0,old=0,older=0; //To store count

int n,freq,count=0,high=0; //to store mode and other

double stdDev,mean,sum=0; //to store stdDev mean and sum

for(int i=0;i<(sizeof(RandomData)/sizeof(RandomData[0]));i++) //loop to count

{

if(RandomData[i]>0&&RandomData[i]<=18)

infant++;

else if(RandomData[i]>18&&RandomData[i]<=29)

young++;

else if(RandomData[i]>29&&RandomData[i]<=50)

middle++;

else if(RandomData[i]>50&&RandomData[i]<=69)

old++;

else if(RandomData[i]>69)

older++;

}

double first=0,sec=0; //to store result of stdDev formula first and second part

for(int i=0;i<(sizeof(RandomData)/sizeof(RandomData[0]));i++) //loop to calculate mean mode and stdDev

{

n=RandomData[i];

count=0;

for(int j=0;j<(sizeof(RandomData)/sizeof(RandomData[0]));j++)

{

if(n==RandomData[j])

count++;

}

if(high<count)

{

freq=RandomData[i];

high=count;

}

first+=(pow((RandomData[i]),2)/(sizeof(RandomData)/sizeof(RandomData[0])));

sec+=RandomData[i]/(sizeof(RandomData)/sizeof(RandomData[0]));

sum+=RandomData[i];

}

mean=sum/(sizeof(RandomData)/sizeof(RandomData[0]));

stdDev=sqrt(first-pow((sec),2));

/*------Printing Result-----*/

cout<<"\nCount:\nInfant: "<<infant<<"\nYoung: "<<young<<"\nMiddle: "<<middle;

cout<<"\nOld: "<<old<<"\nOlder: "<<older;

cout<<"\n\nMean: "<<mean<<"\nMode: "<<freq<<"\nStandard Deviation: "<<stdDev;

/*-----------XXXX-------------*/

getch();

}

You might be interested in
A ______ connection provides fast internet service and the ability to exchange large files. ​
Degger [83]

Answer:

broadband

Explanation:

A<u> broadband</u> connection  provides fast internet service and the ability to exchange large files. ​

3 0
3 years ago
Finish the statement below to correctly describe the Defense Enrollment Eligibility Reporting System (DEERS). DEERS is a central
WITCHER [35]

Answer:  A- the antlers and horns are structural adaptations. The fighting is a behavioral adaptation.

Antlers and horns are physical adaptations that some mammals have acquired over time. However, fighting is not a physical feature but a behavioral adaptation used to beat other males during mating season.

Explanation:

5 0
3 years ago
Why is it important to cite your sources?
emmainna [20.7K]

Answer:

It gives credit to the original author and shows that you are not taking credit for someone

else's work

7 0
3 years ago
Read 2 more answers
What is the half of 3/18
Zarrin [17]

Answer:

1/3

Explanation:

3/18 divided by 2 equals 1/3

hope this helps

have a good day

5 0
2 years ago
Given a string variable s that has already been declared, write some code that repeatedly reads a value from standard input into
valina [46]

Answer:

The code to this question can be given as:

Code:

while ((s!="Y" && s!="y" && s!="N" && s!="n"))  //loop for check condition

{

cin >> s;  //insert value

}

Explanation:

The description of the following code:

  • In this code, we use a string variable s that has been to define in question.
  • In code, we use a while loop. It is an entry control loop in loop we check variable s value is not equal to "y", "Y", "n" and "N".  
  • In the loop we use AND operator that checks all value together. If this is true So, we insert value-form user input in string variable that is "s".
4 0
3 years ago
Other questions:
  • David would like to send a letter to more than one hundred people. He would like the letter to have names and addresses inserted
    7·1 answer
  • Blogs are typically written by large companies or organizations as a way to express formal, technical, or scholarly information
    5·2 answers
  • Which statement best describes a scientific theory?
    13·1 answer
  • What to do when the tool bar for paint tool sai dissapears?
    12·1 answer
  • HELP ASAP
    9·1 answer
  • Whats the answer to this question?
    7·1 answer
  • When a client computer wants to connect to a service instance, what specific name type does it use to find the service?
    9·1 answer
  • What will the declaration below do to its target?
    9·1 answer
  • if anyone is on a Chromebook, do you ever mean to press backspace, then you accidentally press the power button and think "OH CR
    13·2 answers
  • I'm in Paris and want to take a picture of my mom in front of the Eifel Tower. I want both her and the tower to be in sharp focu
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!