C++ tutorial, C++ programs, C++ Exercises, C++ Example Programs

Thursday, December 12, 2013

Program Number Raise To the Power by Loop

Program Number Raise To the Power For Loop, Program to calculate power of a number by for loop
/*
Write a C++ Program to get two numbers from the user,
and Calculates and displays the result of first number
raise to the power of second number. Use For Loop.

For Free C++ Programming Techniques (Example Programs), visit
Www.EasyCppProgramming.Blogspot.Com

and For Good Notes
Visit   Www.ForFreeEducation.Blogspot.Com
*/
#include<iostream.h>

#include<conio.h>

void main()
{

  clrscr();

  int number, power, counter;
  long result=1;

  cout<<"\n Enter the Number = ";

  cin>>number;

  cout<<"\n Enter the power = ";

  cin>>power;

  for ( counter = 1; counter <= power; counter++)
      result = result * number;

  cout<<"\n\n ----------- Results ------------";

  cout<<"\n\n The Result of "<<number<<" rasie to the power "<<power<<"\nis "<<result;

  getch();

}

Share:

0 comments:

Post a Comment

We Love To Hear From You!

EasyCPPprogramming.blogspotcom

Blog Archive

Labels