is it right

# 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;
}
Does it work?
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;
}
yes
What do you mean by timing? cin is what is stopping your program and waiting for the user to enter input.
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.
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.
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.