Search
 
SCRIPT & CODE EXAMPLE
 

C

find power of a number in c

#include <stdio.h>  
#include <math.h>  
int main ()  
{  
// declare base and exp variable   
int base, exp;  
int result; // store the result  
printf (" Enter the base value from the user: ");  
scanf (" %d", &base); // get base from user  
printf (" Enter the power value for raising the power of base: ");  
scanf (" %d", &exp); // get exponent from user  
  
// use pow() function to pass the base and the exp value as arguments  
result = pow ( base, exp);  
printf (" %d to the power of %d is = %d ", base, exp, result);  
return 0;  
}  
Comment

C program to find power of any number

/**
 * C program to find power of any number
 */

#include <stdio.h>
#include <math.h> // Used for pow() function

int main()
{
    double base, expo, power;

    /* Input two numbers from user */
    printf("Enter base: ");
    scanf("%lf", &base);
    printf("Enter exponent: ");
    scanf("%lf", &expo);

    /* Calculates base^expo */
    power = pow(base, expo);

    printf("%.2lf ^ %.2lf = %.2lf", base, expo, power);

    return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: esp32 dhcp server 
C :: how to join an array of strings c 
C :: how to use pointer in c to print char 
C :: string in c and how it works 
C :: read from command line c 
C :: while loop in c 
C :: integer in c 
C :: %g and %e in c 
C :: how to print logs when doing unit-testing in rust 
C :: english to russian translation 
C :: Install valet-linux 
C :: *= in c 
C :: printing words lemgthwise in c 
C :: how to declare an array of n numbers in c 
C :: le reste de division in algorithm c 
C :: como somar em C 
C :: how can i learn c game development 
C :: best graphic video template for editing free download 
C :: pointer operator 
C :: pointeur de pointeur en language c 
C :: c to assembly converter online 
C :: Entering raw mode 
C :: Trier lexicographiquement en c 
C :: shortest job first 
C :: change no_turbo 
C :: unity read text file line by line 
C :: To get file info 
C :: Dividing canvas in live2d 
C :: what is implicit typecasting 
C :: jframe mittig positionieren 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =