Flash Website Builder- Trendy Site Builder is a Flash Site Building tool that helps users build stunning websites. Check Out Custom Custom Logo Design by LogoBee. Website Design and Free Logo Templates available.
 CodingForums.com Arithmetic Operation Problem

Before you post, read our: Rules & Posting Guidelines

Enjoy an ad free experience by logging in. Not a member yet? Register.
 09-24-2011, 09:32 AM PM User | #1 ashishchaudhary New Coder   Join Date: Sep 2010 Posts: 27 Thanks: 2 Thanked 0 Times in 0 Posts Arithmetic Operation Problem hello Every one, Today my problem is much complex for me, I am so confused why is this happening; The problem is if i have a = 2; ********** In C Language ********** and i perform i = a++ + ++a + --a + a-- + ++a; then result is = 15 i = a++ + ++a + --a + a--; then result is = 8 ************ In Java Language ************ i = a++ + ++a + --a + a-- + ++a; then result is = 15 i = a++ + ++a + --a + a--; then result is = 12 I don't know why is this happening, what is the reasion, I am performing the same operation but the result is different. Please give me the detail description about this. Thank You.
 09-24-2011, 07:03 PM PM User | #2 chris0 New Coder   Join Date: Sep 2011 Posts: 45 Thanks: 1 Thanked 6 Times in 6 Posts thats interseting, make sure you that the initial value of a is the same in java and in c try to divide it with brackets i = (a++) + (++a) + (--a) + (a--); and see if that makes a difference
 09-25-2011, 08:11 AM PM User | #3 ashishchaudhary New Coder   Join Date: Sep 2010 Posts: 27 Thanks: 2 Thanked 0 Times in 0 Posts Thanks for your reply chris0. But the problem is same as it is yet. for the java the program is public class test { public static void main(String ar[]) { int a=2,j=0,k=0; j = a++ + ++a + --a + a-- + ++a; k = a++ + ++a + --a + a--; System.out.println("The value of j = " + j + " and the value of k = " + k); } } then the result is The value of j = 15 and the value of k = 12 Also if i seperate all of them with parenthesis like you told (a++) then the result is same. for c the program is int main(void) { int a=2,j=0,k=0; clrscr(); j = a++ + ++a + --a + a-- + ++a; k = a++ + ++a + --a + a--; printf("The value of j = %d and the value of k = %d", j,k); getch(); return 0; } then the result is The value of j = 15 and the value of k =8 I used parenthesis Alos, but nothing happened. Please give me the detail description about this problem. thank you.

 Bookmarks

 Thread Tools Rate This Thread Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home :: Client side development     JavaScript programming         DOM and JSON scripting         Ajax and Design         JavaScript frameworks         Post a JavaScript     HTML & CSS     XML     Flash & ActionScript         Adobe Flex     Graphics and Multimedia discussions     General web building         Site reviews         Building for mobile devices :: Server side development     Apache configuration     Perl/ CGI     PHP         Post a PHP snippet     MySQL         Other Databases     Ruby & Ruby On Rails     ASP     ASP.NET     Java and JSP     Other server side languages/ issues         ColdFusion         Python :: Computing & Sciences     Computer Programming     Computer/PC discussions     Geek News and Humour Web Projects and Services Marketplace     Web Projects         Small projects (quick fixes and changes)         Medium projects (new script, new features, etc)         Large Projects (new web application, complex features etc)         Unknown sized projects (request quote)         Vacant job positions         Looking for work/ for hire         Project collaboration/ partnership         Paid work offers and requests (Now CLOSED)     Career, job, and business ideas or advice     Domains, Sites, and Designs for sale         Domains for sale         Websites for sale         Design templates and graphics for sale :: Other forums     Member Offers     Forum feedback and announcements

All times are GMT +1. The time now is 02:57 AM.