Wipro
Company
Programming
Database
What is the output of the following program:
#include
void main()
{
printf("%d %o %x",65,65,65);
}
Read Solution (Total 10)
-
- Output : 65, 101, 41
%d => prints the decimal representation of 65
%o => prints the octal representation of 65
[ie divide 65 by 8]
8|65
-----
8|8 - 1
---------
1 - 0
--------
So octal representation of 65 is 101
%x => prints the hexa-decimal representation of 65
[ie divide 65 by 16]
16|65
-----
16|4 - 1
------------
So hexa-decimal representation of 65 is 41
So o/p : 65, 101, 41 - 10 years agoHelpfull: Yes(61) No(2)
- Printf() Std O/P Function is There in Stdio or stdlib Header Files Which r not included properly So Gives an Error!!!!!!
- 10 years agoHelpfull: Yes(6) No(3)
- o/p:65,101,41
Bcz %d is decimal notation so 65 is decimal number so without converting we directly printing value 65.%o is octal notation so convert decimal number to octal number by dividing 65 with 8 then we get 101.
65/8 gives 8 as quotient and 1 as remainder and again divide quotient 8 with 8 then we get 1 as quotient and 0 as remainder this process is repeated until the quotient is divisible by 8 then the result should be remainders which are to be taken from last to first ie,101.
next,%x is hexadecimal notation so convert decimal to hexa similar to octal bt we have to divide 65 with 16 then the result is 41 - 10 years agoHelpfull: Yes(4) No(1)
- %d format specifier is used for printing integer
%o format specifier is used for printing octal
%x format specifier is used for printing hexadecimal
so the answer is 65 101 41 - 10 years agoHelpfull: Yes(3) No(1)
- %d means integer
65-->65
%o means octal
65-->110101
%x means hexadecimal
65-->01010101 - 10 years agoHelpfull: Yes(1) No(2)
- ma'am..!! didn't get to you..pls xplain it more clearly..
- 10 years agoHelpfull: Yes(0) No(0)
- 65 81 41
%d prints integer equivalent of the given value Similary %o gives octal equivalent and %x gives hexadecimal Equivalent - 10 years agoHelpfull: Yes(0) No(5)
- 65,101,41
- 9 years agoHelpfull: Yes(0) No(0)
- 1:9: error: #include expects "FILENAME" or
#include
^
In function 'main':
4:5: warning: incompatible implicit declaration of built-in function 'printf' [enabled by default]
printf("%d %o %x",65,65,65);
^ - 9 years agoHelpfull: Yes(0) No(0)
- output is:
65 101 41 - 5 years agoHelpfull: Yes(0) No(0)
Wipro Other Question