what is the program output

This is a discussion on what is the program output within the C Programming forums, part of the General Programming Boards category; 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 ...

  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
    Super Moderator
    Join Date
    Sep 2001
    Posts
    4,913
    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, 06:24 AM
  2. calling an external program + capture output?
    By cyberfish in forum C++ Programming
    Replies: 4
    Last Post: 03-21-2008, 01: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, 09:25 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21