Computer Science, asked by evilqusai, 1 month ago

Slip 1
Q1.Write a 'C' program to find x^y, take the values of x and y from the user.
[15​

Answers

Answered by anindyaadhikari13
1

Solution:

The given cøde is written in C –

#include <stdio.h>

#include <math.h>

int main(){

double a,b;

printf("Enter first number: ");

scanf("%lf",&a);

printf("Enter second number: ");

scanf("%lf",&b);

printf("%lf^%lf = %lf",a,b,pow(a,b));

return 0;

}

  • The pow() function returns first number raised to the power second number. So here, I have taken two numbers as input and then calculated the result using pow() function.
  • The pow() function is present in math.h header file. So, it is necessary to import this header file.

See the attachment for output.

Attachments:
Similar questions