Thread: what is the program output

  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    8

    what is the program output

    Code:
    #include<stdio.h>
    #define PR(a)   printf("%d\t",(int) (a));
    #define PRINT(a,b,c) PR(a);PR(b);PR(c);
    #define MAX(a,b) (a<b?b:a)
    main(){
    	int x = 1,y = 2;
    		PRINT(MAX(x++,y),x,y);
    			PRINT(MAX(x++,y),x,y);
    			}
    in the output
    first itis printing 2 2 2 it's ok
    but in the second 3 4 2 is printing
    why it is printing 4 .increment is done only one time after fitst printf

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4,912
    x is incremented after the first PRINT(), and is incremented after the first parameter to the second PRINT() is evaluated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 05-29-2010, 05:24 AM
  2. calling an external program + capture output?
    By cyberfish in forum C++ Programming
    Replies: 4
    Last Post: 03-21-2008, 12:49 AM
  3. program looping with final output
    By hebali in forum C Programming
    Replies: 24
    Last Post: 02-28-2008, 10:58 AM
  4. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  5. Redirecting program output straight to an edit control
    By bennyandthejets in forum C++ Programming
    Replies: 5
    Last Post: 07-05-2004, 08:25 AM