Skip to content

Instantly share code, notes, and snippets.

@jagdish4501
Created March 30, 2021 07:24
Show Gist options
  • Save jagdish4501/3073b5854d6bcbb22b7f339352d816a0 to your computer and use it in GitHub Desktop.
Save jagdish4501/3073b5854d6bcbb22b7f339352d816a0 to your computer and use it in GitHub Desktop.
Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.
#include <stdio.h>
int main()
{
int a, b, c, pow = 1;
printf("enter the value of a, b");
scanf("%d%d", &a, &b);
for (c = 1; c <= b; c++)
{
pow = pow * a;
}
printf("pow(%d,%d)=%d", a, b, pow);
}
--------->>>>>
//second methode using <math.h> header file
#include <stdio.h>
#include <math.h>
int main()
{
int a, b, c;
printf("enter the number a & b ");
scanf("%d : %d", &a, &b);
c = pow(a, b);
// c=a^b or pow(a,b)=a^b
printf("c=%d", c);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment