Kevin321888999

exercise functions 2 (pow())

Feb 23rd, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. #include <stdio.h>//library for printf and return 0
  2. double pow(double X, double Y);// This will tell the computer to square X (base) by however many times Y (the exponent). Although I don't really need it, because of the math.h library.
  3. int main(void){
  4.   double X;//assign the variables as doubles
  5.   double Y=2; // because the lab asks for the number to be squared I set the exponent to 2.
  6.   double sum;
  7.   printf("Please Enter Variables: ");
  8.   scanf("%lg",&X);
  9.   sum= pow(X,Y);// because of the math.h library, the computer will take the number that the user inputs and plug them into the equation.
  10.   printf("This is the answer: %g",sum);//don't need to scanf sum because the sum is already defined to the equation pow(X,Y).
  11.   return 0;
  12.   }
  13.  
Advertisement
Add Comment
Please, Sign In to add comment