Exponentional Function(LONG INT)


#include <stdio.h>
int expo(int a,int b){
    int c =1;
    for(int i=1;i<=b;i++){
        c = c*a;
    }
    return c;
}
int main(){
//Long Int CODE:
long int a,b;
label:
    printf("Enter base: ");
    scanf("%ld",&a);
    printf("Enter power: ");
    scanf("%ld",&b);
    long int d = expo(a,b);
    printf("Result is %ld\n",d);
    goto label;
return 0;
}

Comments

  1. //x**y can also be taken as x*x*x*x.....(y times).
    So we took a variable having value =1.....and keep multiplying 'x' with it 'y' times.
    same is the procedure with multiplication operator(a*b).....we take int n=1.....and keep summing 'a', 'b' times .

    ReplyDelete

Post a Comment

Popular Posts