EmbLogic's Blog

problem in assingment 01

  1. int main(void)
  2. {
  3.    int  x=100;
  4.     printf(“dec=%d; octal=%o; hex=%x\n”,x,x,x);
  5.   printf(“dec=%d;octal=%#o;hex=%x\n”,x,x,x);
  6.   return 0;
  7. }

why we add # into the formate specifier ……………….why compiler printing the same value 100  after using the same format specifier %d in all case………..

One Response to problem in assingment 01

  1. m siddarth says:

    To print any values in decimal format/Octal format or in hexadecimal format we can implement both the printf statements however the only difference is while printing the second statement we get the output in a proper format about the formats usage in Compiler.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>