Read two numbers and raise the first one to the power of second one - C Operator

C examples for Operator:Arithmetic Operator

Description

Read two numbers and raise the first one to the power of second one

Demo Code

#include <stdio.h>  
#include <stdlib.h>      
#include <math.h>        
  
int main(int argc, char *argv[])  {  
    double num, exp;  
      //  www  .  ja  va2s. c  o  m
    if (argc != 3)  
        printf("Usage: %s number exponent\n", argv[0]);  
    else {  
        num = atof(argv[1]);  
        exp = atof(argv[2]);  
        printf("%f to the %f power = %g\n", num, exp, pow(num,exp));  
    }  
      
    return 0;  
}

Related Tutorials