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

Describe newline escape sequence with a sample program?

645


How do we declare variables in c?

561


Wt are the Buses in C Language

2744


Explain low-order bytes.

617


What would happen to X in this expression: X += 15; (assuming the value of X is 5)

1293






write a program to display all prime numbers

1450


Write a program to print “hello world” without using semicolon?

667


What could possibly be the problem if a valid function name such as tolower() is being reported by the C compiler as undefined?

736


What does int main () mean?

540


How can I change their mode to binary?

687


Why is c called c?

620


Define Spanning-Tree Protocol (STP)

638


Write a program of prime number using recursion.

611


What is the explanation for prototype function in c?

562


Describe the modifier in c?

597