For loop with int value type as the control : For « Language « C++






For loop with int value type as the control

For loop with int value type as the control

#include <iostream>
using namespace std;

int main()
{
  int b, e, r;
  cout << "Enter base: ";
  cin >> b;
  cout << "Enter exponent: ";
  cin >> e;

  r = 1;
  for( ; e; e--) 
     r = r * b;
  
  cout << "Result: " << r;

  return 0;
}


           
       








Related examples in the same category

1.For statementFor statement
2.for loop: A Multiplication Tablefor loop: A Multiplication Table
3.Generating digit numbers of equally total digits