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

Please explain in detail how to deal with these problems The constant p (PI) is

ID: 3667042 • Letter: P

Question

Please explain in detail how to deal with these problems The constant p (PI) is used in many trigonometric applications. There are several ways to store and work with p in the C Language. Show how to implement the following by completing the code segment for each method a through d. Verify each segment works correctly by testing it (compile and execute your program on the Omega gee compiler). Define a variable of type float for PI in the main function. How many digits are you able to use in part a? Define a variable of type double for PI in the main function. How many digits are you able to use in part b? Define a constant using a macro definition for PI in the preprocessor section. How many digits are you able to use in part c? How are constants (macros) handled differently in C? (Is this stored the same way as a variable?) Use the M_PI constant from the math.h library. How many digits are in the M_PI constant.

Explanation / Answer

#include<stdio.h>
#include<math.h>

#define PI 3.1415926535897932384626433832795028841971693993751058209749445923078164
int main(){
  
   //part A
   float a = 3.1415926535897932384626433832795028841971693993751058209749445923078164;
   printf("%g ",a);
  
   //part B
   double b = 3.1415926535897932384626433832795028841971693993751058209749445923078164;
   printf("The value of PI is: %g ",b);
  
   //part C
   printf("The value of PI is: %g ",PI);
  
   //part D
   printf("The value of PI is: %g ",M_PI);
   return 0;
   }