is it right

Jun 30, 2010 at 1:21pm
# include <iostream>
using namespace std;
int main(void)
{
float a, b, result;
char symbol;
cout << "enter first number a: ";
cin >> a;
cout << "enter second number b: ";
cin >> b;
cout << "Enter the operation you want to done: [(+),(-),(*),(/)]";
cin >> symbol;
if (symbol == '+' )
{
cout << "you have pressed + \n";
result = a + b;
cout << result<<endl;
}
else if (symbol == '-')
{
cout << "you have prressed - \n";
result = a - b;
cout << result <<endl;
}
else if (symbol == '*')
{
cout << "you have pressed * \n";
result = a * b;
cout << result <<endl;
}
else if (symbol == '/')
{
cout << "you have pressed / \n";
result = a / b;
cout << result <<endl;
}
else
{
cout << "you have entered an invalid function!!! \n";
}
system("pause");
return 0;
}
Jun 30, 2010 at 1:25pm
Does it work?
Jun 30, 2010 at 2:13pm
how can i set the timing to while loop

# include <iostream>
using namespace std;
int main(void)
{
int i;
float a, b, result;
char symbol;
while (i = 3)
{
cout << "enter first number a: ";
cin >> a;
cout << "enter second number b: ";
cin >> b;
cout << "Enter the operation you want to done: [(+),(-),(*),(/)]";
cin >> symbol;
if (symbol == '+' )
{
cout << "you have pressed + \n";
result = a + b;
cout << result<<endl;
}
else if (symbol == '-')
{
cout << "you have prressed - \n";
result = a - b;
cout << result <<endl;
}
else if (symbol == '*')
{
cout << "you have pressed * \n";
result = a * b;
cout << result <<endl;
}
else if (symbol == '/')
{
cout << "you have pressed / \n";
result = a / b;
cout << result <<endl;
}
else
{
cout << "you have entered an invalid function!!! \n";
}
}
system("pause");
return 0;
}
Jun 30, 2010 at 2:13pm
yes
Jun 30, 2010 at 3:03pm
What do you mean by timing? cin is what is stopping your program and waiting for the user to enter input.
Jun 30, 2010 at 5:28pm
Please do the following things for us:

1) Use the proper formatting tools located at the right hand side of comment box to properly paste your code.

2) In a few sentences, please do your best to say what it is you need help with.

Thanks.
Jul 1, 2010 at 4:30pm
is it right

It might be even just more left than expected. This minor fluctuation in our generally accepted hypothesis is a common misconception which is (by our hypothesis) caused by the disability to determine directions. It is this that causes left and right to be completely undefined and arbitrary. Furthermore there should be noted that, although the before said is completely true, you might really even have been gone far as decided to go even want to do look more like.

My hobby: Trying to make a point by trolling non-descriptive threads.
Jul 1, 2010 at 4:45pm
khalidhussain wrote:
how can i set the timing to while loop

I think he wants to run the while loop for a finite number of times. Well, you could just use a for loop but with while you can do it like this:

1
2
3
4
5
6
7
8
int counter=0;
while (counter<10)
{
    counter++;

    //rest of your
    //loop here...
}
Topic archived. No new replies allowed.