Question: Convert this C Code to an ARMv8 Code program: #include long long int factorial(int n) //function to calculate factorial of integer numbers { if(n==0 ||

Convert this C Code to an ARMv8 Code program:

#include

long long int factorial(int n) //function to calculate factorial of integer numbers { if(n==0 || n==1) //factorials of 1 n 0 are 1 { return 1; } return n*factorial(n-1); //using recursion }

float power(float number,int p) //power function for number raised to integer power p. { if (p==0) { return 1; //zero power results in 1. } if(p==1) { return number; } return number*power(number,p-1); }

int main() { double x,result ; //user input x and result variable for calculation long long int a; //64 bit user input no. a int n; //loop counter variable

printf("Enter a value of X between -5 and 5: "); //getting user input for x scanf("%lf",&x); //storing x in double

while(x>5 || x<-5) { printf("Please enter a new value of X between -5 and 5: "); //getting user input for x scanf("%lf",&x); //storing x in double }

printf("Enter the value of A less than 16: "); //getting user input for a scanf("%lli",&a); //storing a in long long int

while(a>16) { printf("Please enter a new value of A less than 16: "); //getting user input for a scanf("%lli",&a); //storing a in long long int }

for(n=0;n<=a;n++) //loop for carrying out summation from n=0 to n=a. { result=result+(double)(power(x,n)/factorial(n)); //calculating (x^n)/n! for each n and adding to previous summation }

printf("The exponential value is: %lf ",result); //printing the value after summation. return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!