Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Program to calculate a^b.
- #include<iostream.h>
- #include<conio.h>
- int pwr(int,int);
- void main()
- {
- clrscr();
- int a,d;
- cout<<"Enter first number: ";
- cin>>a;
- cout<<"Enter second number: ";
- cin>>d;
- cout<<"A^B: "<<pwr(a,d);
- getch();
- }
- pwr(int a,int d)
- {
- int i,b=1;
- for(i=1;i<=d;i++)
- b=b*a;
- return b;
- }
Advertisement
Add Comment
Please, Sign In to add comment