Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Q:-1Estimating the Adult Height of a Child Hmale_child = ((Hmotherx 13/12) + Hfa

ID: 3536526 • Letter: Q

Question

Q:-1Estimating the Adult Height of a Child Hmale_child = ((Hmotherx 13/12) + Hfather)/2 Hfemale_child = ((Hfather x 12/13) +Hmother)/2 Using the formulas above, write a program that takes as INPUTthe gender of the child, the height of the mother in inches, andthe height of the father in inches, and outputs the estimated adultheight of the child in inches. Write appropriate methods as a part of the solution. The height of the child can not be zero. The program should allow the user to enter a new set of values and output the estimated height until the user decides to exit.
Q2:- After creating the code in first one modify the code such that the gender and estimated adult height for each child are stores in appropriate arrays. Based upon the data in the array the program should then calculate and dsiplay the average height of male children and average height of female children.

Q3:- Modify the code in question 2 such that the gender and the estimated adult height data in the arrays is written to a text file. The name of the text file is to be obtained from the user. If the file already exists it should not be overwritten. Instead obtain a new filename from the user until the filename supplied form the user doesn't exist. Each line of text file should represent one child. the data on each line should be the gender followed by the estimated adult height.

Q:-1Estimating the Adult Height of a Child Hmale_child = ((Hmotherx 13/12) + Hfather)/2 Hfemale_child = ((Hfather x 12/13) +Hmother)/2 Using the formulas above, write a program that takes as INPUTthe gender of the child, the height of the mother in inches, andthe height of the father in inches, and outputs the estimated adultheight of the child in inches. Write appropriate methods as a part of the solution. The height of the child can not be zero. The program should allow the user to enter a new set of values and output the estimated height until the user decides to exit.
Q2:- After creating the code in first one modify the code such that the gender and estimated adult height for each child are stores in appropriate arrays. Based upon the data in the array the program should then calculate and dsiplay the average height of male children and average height of female children.

Q3:- Modify the code in question 2 such that the gender and the estimated adult height data in the arrays is written to a text file. The name of the text file is to be obtained from the user. If the file already exists it should not be overwritten. Instead obtain a new filename from the user until the filename supplied form the user doesn't exist. Each line of text file should represent one child. the data on each line should be the gender followed by the estimated adult height.

Explanation / Answer


part a


#include<stdio.h>

#include<conio.h>

int height(char gender,int Hmother,int Hfather)

{

if(gender=='M')

return ((Hmother * 13/12) + Hfather)/2;

else

return ((Hfather * 12/13) +Hmother)/2;

}

int main()

{

int Hfather,Hmother,choice=1;

char gender;//'M' for male and 'F' for female

while(1)

{

printf("enter gender('M' for male and 'F' for female) , also enter height of mother ,height of father of the child : ");

scanf("%c%d%d",&gender,&Hmother,&Hfather);

printf(" The height of the child is : %d ",height(gender,Hmother,Hfather));

printf("press 1 to continue press 0 to exit :");

scanf("%d",&choice);

if(choice==0)break;

}

getch();

return 0;

}