Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

calculate the valueof a^n both a and n are positve

0 votes
asked May 19, 2018 by anonymous

1 Answer

0 votes
answered May 20, 2018 by chandni23 (180 points)
#include <stdio.h>
int A_N(int a,int n);
int main()
{
    int a,n,result;
    printf("Enter a positive number a\n");
    scanf("%d",&a);
    
    printf("Enter a positive num N\n");
    scanf("%d",&n);
    
    result = A_N(a,n);
    printf("Result for a^n =%d\n",result);

    return 0;
}
int A_N(int a,int n)
{
    int i,result=1;
    for(i=1;i<=n;i++)
    {
        result *= a;
    
    }
    return result;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...