main()
{
int a = 65;
printf(“%d %o %x”,a,a,a);
}
Output
65 101 41
Please explain me.How it is coming like that?
Answer Posted / chandan
printf(�%d %o %x�,a,a,a);
1) We can use ? sign instead of " sing in pintf statement .
2)First o/p value 65 ,is the decimal value of int a.
3)2nd o/p value 101 , is the octal value of int a.
i.e base is 8.
8^2 8^1 8^0
1 0 1
it Works 8^2 *1 + 8^1 *0 + 8^0*1 = 64*1 + 8*0 + 1*1=64+0+1=65
it is actual input decimal value.
Similarly,
4)3rd o/p value 41 , is the Hexadecimal value of int a.
i.e base is 16.
16^1 16^0
4 1
it Works 16^1 *4 + 16^0*1 = 16*4 + 1*1=64+1=65
it is actual input decimal value.
| Is This Answer Correct ? | 2 Yes | 0 No |
Post New Answer View All Answers
Is exit(status) truly equivalent to returning the same status from main?
Explain about C function prototype?
Is there any algorithm to search a string in link list in the minimum time?(please do not suggest the usual method of traversing the link list)
What is the use of a semicolon (;) at the end of every program statement?
Who invented bcpl language?
How can type-insensitive macros be created?
What are valid operations on pointers?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;
What do you mean by keywords in c?
Write a program to reverse a string.
What are identifiers and keywords in c?
write a c programming using command line argument,demonstrate set operation(eg;union,intersection,difference) example output is c:>setop 12 34 45 1 union 34 42 66 c:>setop 12 34 1 42 66 c:>setop 12 34 diff 12 56 67 78 setop 12 34
What is array in C
What are the parts of c program?
What is the difference between text and binary i/o?