How does Increment operator work in Java?

What wrong wiz this c++ code please?

  • The first line of the input file contains an integer T specifying the number of test cases. Each test case is preceded by a blank line. Each test case represents one sequence of button presses for a pocket calculator. The sequence consists of non-negative integers and arithmetic operators and ends with an equal sign. It may also contain spaces to improve readability. The operator / represents integer division, rounded down. You may assume that no test case contains division by zero and that in all test cases all intermediate results are non-negative. Tip: long long int in C/C++, long in Java or int64 in Pascal is enough for this problem. Output specification For each sequence from the input file output the number that would be displayed on the calculator. Example Input: 4 1 + 1 * 2 = 29 / 5 = 103 * 103 * 5 = 50 * 40 * 250 + 791 = Output: 4 5 53045 500791 Hint The first test case shows that there is no operator precedence. The second one shows that integer division always rounds down. The last two outputs are the answers to the two riddles in the problem statement: "shoes" (53045 upside down), and "igloos"(500791 upside down). Here's all i could write in this code & it doesn't work :( #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { int T; cin>>T; int x,y; char a; for(int i=0; i<T;i++) { cin>>x; while (a!='=') { cin>>a>>y; if(a=='+') cout<<x+y; else if (x=='-') cout<<x-y; else if (x=='*') cout<<x*y; else if(x=='/') cout<<x/y; } } system("PAUSE"); return EXIT_SUCCESS; } Any help,Plz?

  • Answer:

    *Cough* Curly Bracket *Cough*

Nature at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Keep trying it yourself and teach yourself, if you cant teach yourself then you cant code.

Alberto Reyes

hahah found the mistake, took me a while but i found it, its a simple mistake.. hint: middle,,,learning coding takes time and persistence......real simple mistake, look at the hint...

John Black

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.