Thread: Output of this code

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    2

    Output of this code

    Code:
    int main()
    {
        int i = 1;
        int result = 1;
        char name[6];
        for(i=1; i<=12; i++);
        {
           result+=i;
           if(result % 13 == 2);
            {  
                 name[1] = (char)(result+2);
                 name[4] = name[1];
           }
        }
        name[0] = (char)(result+5);
        name[3] = name[0];
        name[2] = (char) (result+4);
        name[5] = (char)(result+3);
    printf("%s : ",name);
    }

  2. #2
    Registered User
    Join Date
    Oct 2012
    Posts
    2
    tried but failed to get the output of this code..please help...its important

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    What are you trying to do here? What's wrong with the output? What should the output be?

    If you can't be specific, your help here will be generally quite low. Terseness is not a good thing in this instance.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    Perhaps you should compare the output of these two programs.
    Code:
    #include <stdio.h>
    int main ( ) {
      int i;
      for ( i = 0 ; i < 10 ; i++ );
      printf("%d\n",i);
      return 0;
    }
    Code:
    #include <stdio.h>
    int main ( ) {
      int i;
      for ( i = 0 ; i < 10 ; i++ )
      printf("%d\n",i);
      return 0;
    }
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what is the output of this code
    By C_Enthusiast in forum C Programming
    Replies: 2
    Last Post: 01-07-2011, 06:07 AM
  2. what is the output of this code?
    By karthik537 in forum C Programming
    Replies: 15
    Last Post: 09-16-2009, 11:20 AM
  3. code output...
    By roaan in forum C Programming
    Replies: 6
    Last Post: 07-03-2009, 02:22 AM
  4. Output of code
    By lesodk in forum C++ Programming
    Replies: 5
    Last Post: 05-17-2009, 08:56 AM
  5. same code different output
    By kashifk in forum C Programming
    Replies: 4
    Last Post: 03-18-2003, 02:51 PM