main()
{
unsigned int k = 987 , i = 0;
char trans[10];
do {
trans[i++] =(char) (k%16 > 9 ? k%16 - 10 + 'a' : '\0' );
} while(k /= 16);
printf("%s\n", trans);
}
Answer Posted / lakshman
first case k=987, i=0.
trans[i++]=(char)(k%16>9?k%16-10+'a':''); means
trans [0]=char(987%16(=61)>9)condition is true so k%16-10+'a' value is print. that value is equal to 61-10|+(ascii value of a, that is equal to 97) so finally we get 98 and that is equal to b,
second case k=61, i=1 this will gives d
third case k=3, i=2 this gives null character.
the final answer is bd
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is indirection? How many levels of pointers can you have?
Tell me what are bitwise shift operators?
given post order,in order construct the corresponding binary tree
What is the explanation for the dangling pointer in c?
What is a void pointer in c?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What are structural members?
Write a program which returns the first non repetitive character in the string?
Iam a B.Tech graduate and completed my engineering in 2009, from 2005 to 2009 and after that i had done nothing.Now i want to do job and get into BPO field . Friends give me suggestions as what to say in interview... if they ask me that what would you had done ... these many years without doing job ??????? pls urgent
Was 2000 a leap year?
Find MAXIMUM of three distinct integers using a single C statement
Why main function is special give two reasons?
What does d mean?
Which are low level languages?
What are logical errors and how does it differ from syntax errors?