Question

C language only please Program 3: Write a C program to analyze the given eye color data. Initialize an array with the following values. Print the ar

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include <stdio.h>

int main()
{
    // index 0 represents color Black similarly
    // 1 - Brown, 2 - Blue, 3 - Green, 4 - Gray, 5 - Total
    int female[]={20,30,10,15,10,85};
    int male[]={25,15,12,20,10,82};
    int total[]={45,45,22,35,20,167};
    int i;
    float f,t;
    float percent;

    printf("EYE COLOR\t   Black \t   Brown \t   Blue \t   Green \t   Gray");
    printf("\nFemale\t");
    for(i=0;i<5;i++)
        printf("\t    %d \t",female[i]);

    printf("\nMale\t");
    for(i=0;i<5;i++)
        printf("\t    %d \t",male[i]);

    printf("\n\nPercent of Females");
    for(i=0;i<5;i++){
        f=female[i];
        t=total[i];
        percent=(f/t)*100;
        printf(" %.2f \t",percent);
    }

    f=total[4];
    t=total[5];
    percent=(f/t)*100;
    printf("\n\nPercent of Gray eye color is %.2f%",percent);
}


Output -

Black Blue EYE COLOR Brown Green Gray Female 20 30 10 15 10 Male 25 15 12 20 10 Percent of Females 44.44 66.67 45.45 42.86 50

Add a comment
Know the answer?
Add Answer to:
C language only please Program 3: Write a C program to analyze the given eye color...
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
  • Eye Color\Gender Females Males TOTAL Brown 20 5 25 Blue 15 30 45 Green 30 50...

    Eye Color\Gender Females Males TOTAL Brown 20 5 25 Blue 15 30 45 Green 30 50 80 TOTAL 65 85 150 1. What is the probability of selecting an individual has brown eyes or is a female? 2. What is the probability of selecting an individual with brown eyes given that they are male? 3. What is the probability of selecting an individual is a female? 4. What is the probability of selecting an individual is a female with brown...

  • An individual can be classified by gender as male, female, by hair color as black, blonde,...

    An individual can be classified by gender as male, female, by hair color as black, blonde, brown, red, unknown, and by eye color as black, brown, green, hazel, unknown. a) How many different classifications are possible (for example, male, with blonde hair, and green eyes)? There are different classifications. b) Construct a tree diagram to determine the sample space. The tree for gender has branches. From each branch of the tree for gender, the tree for hair color has branches...

  • Please Help, I will rate either way because of the effort. Description: help in c++, this...

    Please Help, I will rate either way because of the effort. Description: help in c++, this program should have 3 files GuessWho.cpp, Person.cpp, Person.h This program will be a Guess Who game. The program should Read the first line of people.txt, Use the contents to set the members of your Person object, Print the Guess Who People heading, Print the Person that you read earlier Prompt the user for a feature (name, haircolor, hairtype, gender, glasses, eyecolor, or hat) Print...

  • Please answer using C ++ programming language ONLY! We have only used <stdio.h> if that helps....

    Please answer using C ++ programming language ONLY! We have only used <stdio.h> if that helps. This is a basic course and the furthest we have gone is BASIC arrays. Write the code for the following problems using arrays. Write what would go in the “int main()” part of the program. For these problems, the entire program and program output is not needed. Just include what goes in the int main() part of the program. 1. Declare an integer array...

  • Uption 4. The inheritance of hair and eye color is very complicated. Scientists have found approximately...

    Uption 4. The inheritance of hair and eye color is very complicated. Scientists have found approximately 10-20 genes responsible for determining hair and eye color in humans (sheesh - I thought a dihybrid cross with 2 genes was bad...). Although many genes are involved in producing these phenotypes, it does seem that just a few genes play a major role in determining the color of our hair and eyes. The following is a simplified, but still somewhat realistic view of...

  • Three resistors with color codes 1. Brown, Brown, Brown, 2. Red, Red, Red 3. Orange, Black,...

    Three resistors with color codes 1. Brown, Brown, Brown, 2. Red, Red, Red 3. Orange, Black, Orange are connected in parallel. A battery of voltage 4.5 V is connected to the resistors. a) Draw the circuit diagram. b) List the values of the resistors according to color code. c) Calculate the equivalent resistance 1st Digit d) Find the current through each resistor e) Add the currents through each resistor to find the total current and use the voltage to find...

  • In need this in C language! Write a program that declares a 40 element array of...

    In need this in C language! Write a program that declares a 40 element array of type double. Initialize the array so that: the first 10 elements are equal to the square of the index variable the next 10 each elements is equal to three times the index variable the next 10 each element is equal to the sum of an element in the first 10 + an element in the second 10 the last 10 each element is equal...

  • In C only Please! This lab is to write a program that will sort an array...

    In C only Please! This lab is to write a program that will sort an array of structs. Use the functions.h header file with your program. Create a source file named functions.c with the following: A sorting function named sortArray. It takes an array of MyStruct's and the length of that array. It returns nothing. You can use any of the sorting algorithms, you would like though it is recommended that you use bubble sort, insertion sort, or selection sort...

  • 1. What would be the phenotype for each of the following birds, including their gender? Color...

    1. What would be the phenotype for each of the following birds, including their gender? Color Gender Bb ZZi: - bb ZiZi: - BB ZZ: - bb ZW: - Bb ZiW: - 2. Using the phenotypes of the parents and of the progeny given in table 1, determine the genotype of each parent in the first nest. Male Female 3. Using the phenotypes of the parents and of the progeny given in table 2, determine the genotype of each parent...

  • Questions 45-46: Consider the following partial table of a sample of 60 M&Ms. We count how...

    Questions 45-46: Consider the following partial table of a sample of 60 M&Ms. We count how many of each color are present. We are testing the null hypothesis that each color has the stated proportion. Observed Counts Assumed Proportions Expected Counts 0.24 13 14 0.20 10 0.16 Color Blue Orange Green Yellow Red Brown Total 11 0.14 6 0.13 6 0.13 60 1.00 60 45. If the null hypothesis is correct, how many orange M&Ms do we expect to see...

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
ADVERTISEMENT