Question
In C: Problem Statement In genetics, most large animals have two copies of every gene, one from each parent. In the simplest genetic model, each
In C:
Problem Statement
In genetics, most large animals have two copies of every gene, one from each parent. In the simplest genetic model, each of the genes takes on one of two forms, usually represented by an uppercase and lowercase letter of the same value ('A' and 'a', for example). The pair of genes typically contributes to the external qualities of the animal in one of two ways. If both genes are uppercase, they contribute in one way, while if both genes are lowercase, they contribute in another way. If one gene is uppercase and the other is lowercase, then the pair acts like either a pair of uppercase genes or a pair of lowercase genes depending on whether the gene represented by the uppercase letter is dominant or recessive, respectively.
In this problem, you will be given two strings, genes1 and genes2, each representing the genes from one parent. Hence, two characters from genes1 and genes2 with the same index make up a single gene. You will also be given a string dominant, telling you whether an uppercase gene is dominant or recessive, represented by 'D' and 'R', respectively (characters of dominant correspond to characters of genes1 and genes2 with the same index).
Your task
You are to return a representing the external qualities of each pair of genes. If a pair of genes has the quality of two uppercase letters, the return should have an uppercase letter, and if not the return should have a lowercase letter. In either case, each letter should have the same value as the corresponding letters of genes1 and genes2.
Constraints
Strings genes1 and genes2 will contain only letters ('a'-'z' and 'A'-'Z').
String dominant will contain only 'D's and 'R's.
Strings dominant, genes1 and genes2 will each contain the same number of characters.
Strings dominant, genes1 and geves2 will each contain between 1 and 50 characters, inclusive.
Corresponding letters in genes1 and genes2 will have the same value, though potentially different cases (uppercase or lowercase).
Example 1:
Input:
AAAA AAaa DRDR
Output:
AAAa
Example 2:
Input:
MGskgzTFQoclnDjZu mgSKGzTFQoClnDJzU DDDDDRDDDDRDDDDDD
Output:
MGSKGzTFQoclnDJZU
#include
#define MAX_LENGTH 50
int main(void) {
char genes1[MAX_LENGTH];
char genes2[MAX_LENGTH];
char dominant[MAX_LENGTH];
char output[MAX_LENGTH];
scanf("%50s", genes1); // Reads maximum 50 characters
scanf("%50s", genes2);
scanf("%50s", dominant);
// YOUR CODE GOES HERE
printf("%s", output);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started