Printing Integer : %x %o %d format specifier : C General Multiple Choice Question



Printing Integer : %x %o %d format specifier : C General Multiple Choice Question


What would be the Output of this Program ?

#include<stdio.h>
void main()
{
printf("%d%o%x",50,050,0x50);
}

[toggle title=”Output”]50 50 50[/toggle]


Why ?

  1. %d format specifier is used for Printing Integer
  2. %o format specifier is used for Printing Octal
  3. %x format specifier is used for Printing Hexadecimal
  4. Any number preceded with Zero (040,050,030) are considered as Octal Numbers
  5. Any number preceded with [ 0x / 0X ] (0x40,0x50,0x30) are considered as Hexadecimal Numbers