WARNING: This program will not work for x power y where the resulting value is greater than 32767. Example: 10 power 10 will give you an incorrect value.
#include <stdio.h>
int main()
{
int num, power,i,ans;
printf("Enter number and power\t");
scanf("%d%d",&num,&power);
ans=num;
for(i=1;i<power;i++)
ans=ans*num;
printf("%d to the power %d = %d",num,power,ans);
return 0;
}
#include<iostream.h>
#include<conio.h>
class abc
{
public:
int a,b,ans;
void show();
void display();
};
void abc::show()
{
cout<<"enter base value:- ";
cin>>a;
cout<<"enter power value:- ";
cin>>b;
}
void abc::display()
{
if(b==0)
{
cout<<1;
}
for(int i=0;i<=b;i++)
{
ans=ans*b;
}
cout<<"Answer is= "<<ans;
}
You can use the 'pow' function. From the 'man' page:
POW(3) Linux Programmer's Manual POW(3)
NAME
pow, powf, powl - power functions
SYNOPSIS
#include
double pow(double x, double y);
float powf(float x, float y);
long double powl(long double x, long double y);
Link with -lm.
DESCRIPTION
The pow() function returns the value of x raised to the power of y.
C. intake, compression, power, and exhaust
c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.
how to create a c program for left factoring.
C-SPAN Bus program was created in 1993.
No you can't. main() is the entry point of a C program where execution starts. Only a single main() can exist in a C program. A program with 2 mains wil not even compile successfully.
int top=-1; int stack[10];
There is a function called pow in header math.h
C. intake, compression, power, and exhaust
Valluru Rao has written: 'Power programming-- Turbo C++' -- subject(s): C++ (Computer program language), Turbo C++ 'Power programming'
Operation C was created on 1991-01-08.
Operation Cobra happened on 1944-07-31.
If you are going to program in turbo c (for DOS) you might be better using DJGPP. Google DJGPP for downloading and a whole host of good info.
C. T. Hirshfeld has written: 'Economic operation of steam turbo-electric stations' -- subject(s): Electric power-plants, Fuel, Management, Steam power-plants
C and C operation
the features of a C program
c program was introduced in the year 1972 by Dennis RitchieNo, it was the C language, not the C program.
I think it is 'execution of a C program'.