write a profram to calculate power of a number

A number and power to be calculated is taken from user.Power is calculated.


Select To use this code as it is.. select and copy paste this code into code.cpp file :)



  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. clrscr();
  6. int n,x,y=1;
  7. cout<<"Please enter x: ";
  8. cin>>x;
  9. cout<<"Please enter n: ";
  10. cin>>n;
  11. //Coding by: Snehil Khanor
  12. //http://WapCPP.blogspot.com
  13. for (int i=1;i<=n;i++)
  14. y=y*x;
  15. cout<<y;
  16. getch();
  17. }

Check out this stream