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

Write a program that prompts the user to enter four integers and reads the four

ID: 3883560 • Letter: W

Question

Write a program that prompts the user to enter four integers and reads the four values with separate scanf statements. Write statements to find the squareroot and cube of each value.   Print the values and their squareroot and their cubes in a labeled table aligned as in the example shown below. Use five lines of output statements. You must use library function to calculate the square and the cube.

Squareroot should be printed out to 4 decimal places as shown below.

Note: The original numbers are being read in as ints…..but squareroot and cube both output doubles. Keep this in mind.

                        Number           Squareroot                   Cube

                          2                         .1415                     8

                        4                       2.0000                      64

                          6                       2.6000                      216

                          8                       2.8900                      512

2. Write a program that prompts a user to enter 3 angles(in degrees) between 0 and 180 degrees. Then print out a table that includes the angle(in degrees), it’s cosine, and it’s tangent. Use the same table format as displayed in 2 above. You must use library functions to calculate the cos and tan. You must define a constant called PI and use that to convert your angles to radians. Output the trig function values to 4 decimal places.

Explanation / Answer

Question 1

#include <stdio.h>
#include <math.h>
int main()
{
int n1,n2,n3,n4;
printf("Enter the number1: ");
scanf("%d", &n1);
printf("Enter the number2: ");
scanf("%d", &n2);
printf("Enter the number3: ");
scanf("%d", &n3);
printf("Enter the number4: ");
scanf("%d", &n4);
printf(" Number Squareroot Cube ");
printf("%d %.4lf %.0lf ",n1,sqrt(n1),pow(n1,3));
printf("%d %.4lf %.0lf ",n2,sqrt(n2),pow(n2,3));
printf("%d %.4lf %.0lf ",n3,sqrt(n3),pow(n3,3));
printf("%d %.4lf %.0lf ",n4,sqrt(n4),pow(n4,3));

return 0;
}

Output:

Question 2

#include <stdio.h>
#include <math.h>
int main()
{
int degree1, degree2, degree3;
printf("Enter the degree1 between 0 and 180: ");
scanf("%d", &degree1);
printf("Enter the degree2 between 0 and 180: ");
scanf("%d", &degree2);
printf("Enter the degree3 between 0 and 180: ");
scanf("%d", &degree3);
printf(" Degree Cosine Tangent ");
printf("%d %lf %lf ", degree1, cos(degree1), tan(degree1));
printf("%d %lf %lf ", degree2, cos(degree2), tan(degree2));
printf("%d %lf %lf ", degree3, cos(degree3), tan(degree3));

return 0;
}

Output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote