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


Please Help Members By Posting Answers For Below Questions

What are dangling pointers? How are dangling pointers different from memory leaks?

617


Which of these functions is safer to use : fgets(), gets()? Why?

631


void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply

2220


write a c program for swapping two strings using pointer

2090


What is the use of sizeof?

550






Function which gives a pointer to a binary trees const an integer value at each code, return function of all the nodes in binary tree.?

618


What is s in c?

607


How to set file pointer to beginning c?

662


Why we use conio h in c?

580


What is the use of f in c?

551


What is character constants?

710


Explain the use of 'auto' keyword

674


differentiate built-in functions and user – defined functions.

619


Write a program to check palindrome number in c programming?

596


What is a shell structure examples?

586