sahajjain01

Calculate a^b.

Aug 19th, 2013
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. //Program to calculate a^b.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. int pwr(int,int);
  5. void main()
  6. {
  7.     clrscr();
  8.     int a,d;
  9.     cout<<"Enter first number: ";
  10.     cin>>a;
  11.     cout<<"Enter second number: ";
  12.     cin>>d;
  13.     cout<<"A^B: "<<pwr(a,d);
  14.     getch();
  15. }
  16.  
  17. pwr(int a,int d)
  18. {
  19.     int i,b=1;
  20.     for(i=1;i<=d;i++)
  21.     b=b*a;
  22.     return b;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment