-->

program to find value of y raised to x using function.


using codeblocks
------------------------------------------------------------------------------------------------------------
//program to find value of y raised to x using function.
#include<stdio.h>                      //header file
#include<math.h>                        //for pow() function
void x_power_y();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
x_power_y();                                     // function calling.
return 0;                                       //returns 0 value
}
void x_power_y()                           // function body line ; also called function definition
{
 int x,y,output;                    // variable declaration
printf("enter a number;base(x)\n");    //message display to input a number
scanf("%d",&x);                //gets input
printf("enter power(y)\n");
scanf("%d",&y);                     //gets value for power.
output=pow(x,y);                    //finds power using pow() function
  printf("y raised to x=%d\n",output);    //display of output.
}

------------------------------------------------------------------------------------------------------
using turbo c++
-----------------------------------------------------------------------------------------------------------
//program to find value of y raised to x using function.
#include<stdio.h>                      //header file
#include<math.h>                        //for pow() function
void x_power_y();                          // function prototype/declaration with return type zero.
int main()                              //main function
{
x_power_y();                                     // function calling.
return 0;                                       //returns 0 value
}
void x_power_y()                           // function body line ; also called function definition
{
 int x,y,output;                    // variable declaration
printf("enter a number;base(x)\n");    //message display to input a number
scanf("%d",&x);                //gets input
printf("enter power(y)\n");
scanf("%d",&y);                     //gets value for power.
output=pow(x,y);                    //finds power using pow() function
  printf("y raised to x=%d\n",output);    //display of output.
}
-----------------------------------------------------------------------------------------------------------------

on some online compiler, this program works even without math,h
But Better if we put it.

No comments:

Post a Comment