Thread: Output of the program

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    53

    Output of the program

    The output of the following program is %

    Code:
    int main()
    {
       printf("%%",7);
       return(0);
     }
    and the output of the following program is also %

    Code:
    int main()
     {
       printf("%",7);
       return(0);
     }
    why ??????

  2. #2
    ... kermit's Avatar
    Join Date
    Jan 2003
    Posts
    1,534
    Not on my machine...

    Both of those examples are kind of silly.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Posts
    100
    What do you expect them to be?

  4. #4
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    The %% is used to print %. Lets say you want to print %d. Then this obviously wont work
    Code:
    printf("%d");
    So you would do this:
    Code:
    printf("%%d");
    (though I haven't ever tested it)

  5. #5
    DESTINY BEN10's Avatar
    Join Date
    Jul 2008
    Location
    in front of my computer
    Posts
    804
    Quote Originally Posted by karthik537 View Post
    The output of the following program is %

    Code:
    int main()
    {
       printf("%%",7);
       return(0);
     }
    and the output of the following program is also %

    Code:
    int main()
     {
       printf("%",7);
       return(0);
     }
    why ??????
    These, I guess, is a sort of undefined behaviour(different on different machines). But the matter to know is that %% is used to print %. For eg.
    Code:
    printf("%%%%"); // output will be %%
    HOPE YOU UNDERSTAND.......

    By associating with wise people you will become wise yourself
    It's fine to celebrate success but it is more important to heed the lessons of failure
    We've got to put a lot of money into changing behavior


    PC specifications- 512MB RAM, Windows XP sp3, 2.79 GHz pentium D.
    IDE- Microsoft Visual Studio 2008 Express Edition

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. calling an external program + capture output?
    By cyberfish in forum C++ Programming
    Replies: 4
    Last Post: 03-21-2008, 12:49 AM
  2. program looping with final output
    By hebali in forum C Programming
    Replies: 24
    Last Post: 02-28-2008, 10:58 AM
  3. Unusual program Output, Help
    By capvirgo in forum C Programming
    Replies: 8
    Last Post: 02-06-2008, 03:13 AM
  4. Redirecting program output straight to an edit control
    By bennyandthejets in forum C++ Programming
    Replies: 5
    Last Post: 07-05-2004, 08:25 AM
  5. Program Output
    By lavon in forum C Programming
    Replies: 1
    Last Post: 03-19-2002, 10:32 PM