QUESTION 2 Part 1: Part 2: Part 3: Part 4: Part 5: CHALLENGE CCTITY2.10.2: Tree
ID: 3746083 • Letter: Q
Question
QUESTION 2
Part 1:
Part 2:
Part 3:
Part 4:
Part 5:
CHALLENGE CCTITY2.10.2: Tree height. Simple geometry can compute the height of an object from the object's shadow length and shadow angle using the formula tan(angleElevation) treeHeight / shadowLength 1. Using simple algebra, rearrange that equation to solve for treeHeight. 2. Write a statement to assign treeHeight with the height calculated from an expression using angleElevation and shadowLength. (Notes) 1 #include 2 > #include «math.h 1 test passed 4 int main(void) double treeHeight; double shadowLength; 5 All tests passed 7 double angleElevation; g 10 scanf("% f", scanf("%lf", &angleElevation); &shadowLength); 12/* Your solution goes here */ 13 14 printf"%lf n", treeHeight); 15 16 17 return 0Explanation / Answer
#include <stdio.h>
#include <math.h>
int main(void) {
double treeHeight;
double shadowLength;
double angleElevation;
scanf("%lf", &angleElevation);
scanf("%lf", &shadowLength);
treeHeight = tan(angleElevation)*shadowLength;
printf("%lf ", treeHeight);
return 0;
}
/*SAMPLE OUTPUT
0.5
4
2.185210
*/
#include <stdio.h>
#include <math.h>
int main(void)
{
int amountToChange;
int numFives;
int numOnes;
scanf("%d", &amountToChange);
numFives = amountToChange / 5;
numOnes = amountToChange % 5;
printf("numFives: %d ", numFives);
printf("numOnes: %d ", numOnes);
}
/*SAMPLE OUTPUT
19
numFives: 3
numOnes: 4
*/
#include <stdio.h>
#include <math.h>
int main(void)
{
int numKidsA;
int numKidsB;
int numKidsC;
int numFamilies;
double avgKids;
scanf("%d", &numKidsA);
scanf("%d", &numKidsB);
scanf("%d", &numKidsC);
scanf("%d", &numFamilies);
avgKids = (numKidsA + numKidsB + numKidsA) / (float) numFamilies;
printf("%lf ", avgKids);
return 0;
}
/*SAMPLE OUTPUT
4
3
5
5
2.200000
*/
#include <stdio.h>
int main(void)
{
char letterToQuit;
int numPresses;
scanf(" %c ", &letterToQuit);
scanf("%d", &numPresses);
printf("Press the %c key %d times to quit. ", letterToQuit, numPresses);
return 0;
}
/*SAMPLE OUTPUT
Press the q key 2 times to quit.
*/
// Note: 4 sub parts at a time please -- Policy of Chegg. Hit the thumbs up if you are fine with the answer. Happy Learning!
#include <stdio.h>
#include <math.h>
int main(void) {
double treeHeight;
double shadowLength;
double angleElevation;
scanf("%lf", &angleElevation);
scanf("%lf", &shadowLength);
treeHeight = tan(angleElevation)*shadowLength;
printf("%lf ", treeHeight);
return 0;
}
/*SAMPLE OUTPUT
0.5
4
2.185210
*/
#include <stdio.h>
#include <math.h>
int main(void)
{
int amountToChange;
int numFives;
int numOnes;
scanf("%d", &amountToChange);
numFives = amountToChange / 5;
numOnes = amountToChange % 5;
printf("numFives: %d ", numFives);
printf("numOnes: %d ", numOnes);
}
/*SAMPLE OUTPUT
19
numFives: 3
numOnes: 4
*/
#include <stdio.h>
#include <math.h>
int main(void)
{
int numKidsA;
int numKidsB;
int numKidsC;
int numFamilies;
double avgKids;
scanf("%d", &numKidsA);
scanf("%d", &numKidsB);
scanf("%d", &numKidsC);
scanf("%d", &numFamilies);
avgKids = (numKidsA + numKidsB + numKidsA) / (float) numFamilies;
printf("%lf ", avgKids);
return 0;
}
/*SAMPLE OUTPUT
4
3
5
5
2.200000
*/
#include <stdio.h>
int main(void)
{
char letterToQuit;
int numPresses;
scanf(" %c ", &letterToQuit);
scanf("%d", &numPresses);
printf("Press the %c key %d times to quit. ", letterToQuit, numPresses);
return 0;
}
/*SAMPLE OUTPUT
Press the q key 2 times to quit.
*/