Like Tree6Likes
  • 3 Post By tabstop
  • 3 Post By tabstop

why it is giving output 1 even though it exceeded octal range? Explain

This is a discussion on why it is giving output 1 even though it exceeded octal range? Explain within the C Programming forums, part of the General Programming Boards category; Code: #include <stdio.h> #include <stdlib.h> int main() { char x='1'; printf("%d",x); return 0; }...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Location
    India
    Posts
    20

    why it is giving output 1 even though it exceeded octal range? Explain

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
     char x='\401';
     printf("%d",x);
     return 0;
    }

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If your question is "what happens when I try to store a value that is too large to fit in the variable I am trying to put it into", the answer is "it gets cut off to fit". Otherwise, reload your question and try again.

  3. #3
    Registered User
    Join Date
    Jul 2011
    Location
    India
    Posts
    20
    If "it gets cut off to fit". can you explain how the 1 value is stored in x?

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Well, that's what's left when you cut off the part that's too big.
    Code:
    your number -> 100000001
    what fits   ->  |______|
    quzah, Salem and ackr1201 like this.

  5. #5
    Registered User
    Join Date
    Jul 2011
    Location
    India
    Posts
    20
    thanking you coder.......

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. what will be the output and plz explain me
    By alekhya k in forum C Programming
    Replies: 6
    Last Post: 06-22-2011, 09:48 AM
  2. output screen isn't giving proper result
    By time4f5 in forum C Programming
    Replies: 11
    Last Post: 03-22-2011, 01:34 AM
  3. structure giving weird output
    By bluetxxth in forum C Programming
    Replies: 7
    Last Post: 02-14-2010, 10:44 PM
  4. help: please explain the output
    By soniclavier in forum C Programming
    Replies: 8
    Last Post: 12-07-2009, 11:35 AM
  5. Input & Output Explain?
    By 98dodgeneondohc in forum C Programming
    Replies: 5
    Last Post: 04-24-2005, 06:13 PM

Tags for this Thread


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