I Have Problem Making This Program .Anybody please make this program for me.THANKS

Write a program to calculate a^b without using any built in function. The values of a and b are to be taken from the user.

Edited 3 Years Ago by New In C++

We do not do your homework for you. What have you done so far? If you are having a problem with something that is one thing. To ask for us to do it for you is completly different.

Edited 3 Years Ago by NathanOliver

Post the code you have so far, so we can see what you have done. Then Daniweb members can try to help you.

A suggestion for NewinC++, it would be a good idea to start with an algorithm prior implementation, then you can understand how your code works.

-ikel

include<iostream>

Using namespace std;
Void main()

int a,b,ans;
cout<<"Enter The Number a="<<a<<endl;
cin>>a;
cout<<"Enter The Number b="<<b<<endl;
cin>>b;
ans=a^b;
cout<<"Answer="<<ans<<endl;

NewInC++,

That's what I suggested earlier, do the algorithm, then do the coding. You said

you want program to takes input till user want to input?

You can start with something like the following;

Begin MyUserInputProgram

Ask for first input
Ask for second input
Compute based on first and second input
   While user want to enter in again, 
      Ask for first input again
      Ask for second input again
      Compute the results again

End MyUserInputProgram

Well, I can see a solution here. Maybe not the best, but by looking at this super simple algorithm, it helps a lot.
-ikel

Edited 3 Years Ago by ikel: Clarity

Oh, actually, I was expecting you to say "wait... why do you use while if other alternatives exist?" I can do something like this too

Begin MyUserInputProgram

Say hello to user
Ask for first input
Ask for second input
Compute based on first and second input
   Ask user if he/she want to continue
   If user want to enter in again, 
      Ask for first input again
      Ask for second input again
      Compute the results again
      Does the user want to repeat operation?
   Else
      Say bye-bye

End MyUserInputProgram

To use while is simple.

while(a_condition == true) {
    //...do something
}

Getting the idea to use it often is not simple.

This article has been dead for over six months. Start a new discussion instead.