Write a program that has the user enter two numbers and then calculates and displays results
the 1st # raised to the 2nd #
the 1st # raised to the 1st #
the 2nd # raised to the 1st #
the 2nd # raised to the 2nd #
NOTE: Use a loop NOT the “pow” function to do this!
This is what I have so far. It's only right when I enter 2 different number like 2 and 3. But when I enter 2 same number. The answer is screw up.
#include <iostream>
using namespace std;
int main (){
//declare variables local to main
int num1,num2,count,count2,count3,count4;
//get user input
cout<<" Please enter two numbers"<<endl;
cin>>num1>>num2;
count = 1;
for (int i = 1; i<= num2; i++){
count = num1 * count;
count2 = num1 * num1;
count3 = num2 * count;
count4 = num2 * num2;}
cout<<num1<<'^'<<num2<<'='<<count<<endl;
cout<<num1<<'^'<<num1<<'='<<count2<<endl;
cout<<num2<<'^'<<num1<<'='<<count3<<endl;
cout<<num2<<'^'<<num2<<'='<<count4<<endl;
return 0;
}