Monday 21, May 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    About Us    |    Contact Us

  finding nth power of any number using c++

Here is a c++ program example to find nth power of any number entered by the user. Number and power to be entered by the user.
Cut & Paste Script
#include<iostream.h>
void main()
{
   
    char repeat='y';
    while(repeat=='y')
    {
        int x,n,a=1,temp;
        cout<<endl;
        cout<<endl;
        cout<<" Enter a number :  ?\b";
        cin>>x;
        cout<<endl;
        cout<<" Enter the power  :  ?\b";
        cin>>n;
        cout<<endl;
        temp=n;
        while(n>=1)
            {
                a = a * x;   
                n--;
            }
    cout<<endl;
    cout<<endl;
    cout<<temp<<"th"<<" power of "<<x<<" is equal to "<<a<<endl;
    cout<<endl;
   
    cout<<" Do you want to do it again ? (y/n)  ";
    cin>>repeat;
    }
}

Output:

Enter a number :  4
Enter the power  :  5
5th power of 4 is equal to 1024
Do you want to do it again ? (y/n)  n
Press any key to continue
 
   
     RELATED SCRIPTS
 
program to display table of digit entered by the user
Here is a program to display table of digit entered by the user using c++....more »
Category : C++ Programs Hits : 679
   
Calculate number of digits in a number using c++
Here is a c++ program example to calculate number of digits in a number entered by user....more »
Category : C++ Programs Hits : 588
   
Program to separate and reverse the 5-digit number
Here is a c++ program example to separate and reverse the 5-digit number entered by the user....more »
Category : C++ Programs Hits : 759
   
Sorting numbers using selection sort in c++
Here is a program example to read a list of integer numbers from keybord and prints them in sorted order. This program is using selection sort to order the integers....more »
Category : C++ Programs Hits : 1492
   
program to show the greatest and smallest number from the given numbers
Program to show the greatest and smallest number from the given numbers using c++. If statement is used in this program....more »
Category : C++ Programs Hits : 790
   
   
SCRIPT CATEGORIES
 
  C Programs
C Programs scripts
  C++ Programs
C++ Programs scripts
  Java Programs
Java Programs scripts
  JavaScript Examples
JavaScript Examples scripts
  PHP Examples
PHP Examples scripts
  VBScript Examples
VBScript Examples scripts
 
 
 
POPULAR E-BOOKS
 
Download Learn to Program Using Python  Ebook Learn to Program Using Python
   
Download The eBay Starters Kit  Ebook The eBay Starters Kit
   
Download Virtualization For Dummies, Sun and AMD Special Edition  Ebook Virtualization For Dummies, Sun and AMD Special Edition
   
Download How to Pick a Shopping Cart System that Makes You Money  Ebook How to Pick a Shopping Cart System that Makes You Money
   
Download Intro to Ebay and Sourcing Guide Ebook Intro to Ebay and Sourcing Guide
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz