TCS
Company
Programming
Program
What is the output of the following program:
void main()
{
printf("%d %d %d %d",65,065,0x65,0X65);
}
Read Solution (Total 10)
-
- O/p: 65, 53, 101, 101
%d always print the decimal form of any number...
65 -> decimal no
065 => octal no. So it ll convert to decimal no.
065=> 000 110 101 => 1*2^0 + 1*2^2+ 1*2^4 + 1*2^5 = 53
0x65 => hexa-decimal number
65 => 0110 0101 => 1*2^0 + 1*2^2 + 1*2^5 + 1*2^6 = 101
0X65 => hexa decimal no.
Hence it ll print 65, 53, 101, 101 - 10 years agoHelpfull: Yes(46) No(2)
- octal to decimal conversion
Octal = 065
Decimal= 0×8²+6×8¹+5×8⁰ = 53
- 10 years agoHelpfull: Yes(3) No(1)
- printf() is predefined method in stdio
but not included - 10 years agoHelpfull: Yes(1) No(4)
- saraswathy..!!! can u tell me hw this 1*2^0 + 1*2^2+ 1*2^4 + 1*2^5 = 53 and 1*2^0 + 1*2^2 + 1*2^5 + 1*2^6 = 101 written??
- 10 years agoHelpfull: Yes(0) No(3)
- priyanka.....
065 is octal no ..convert it to binary so the binary value is 000 110 101 ...now convert this binary no to decimal ..so 1*2^0 + 1*2^2+ 1*2^4 + 1*2^5 = 53... - 10 years agoHelpfull: Yes(0) No(5)
- 65
53 => 065 is in octal notation ..after converting it into decimal 53
101 => from hex to decimal
101 - 10 years agoHelpfull: Yes(0) No(1)
- ans:65 53 101 101
- 10 years agoHelpfull: Yes(0) No(0)
- error in program , there is no declaration
- 9 years agoHelpfull: Yes(0) No(0)
- it shows error.."compile error:variable not defined"
- 7 years agoHelpfull: Yes(0) No(0)
- 65,53,101,101
- 7 years agoHelpfull: Yes(0) No(0)
TCS Other Question