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 / ashok kumar

answer is : bd
Explanation:
trans[i++]= (char) (k%16>9?k%16-10+'a':'');// 1.(char) is typecasting it convert decimal value into character. 2. k=987%16 is greater than 9 means first condition run else second condition as of this k%16 remainder is 11 so it is greater than 9, then first condition will run.
3. 11-10+'a' = 1+'a' = 1+97 is ascii value for a = 98 is ascii value for b so it print.
4. check while condition k=k/16 = 61, so its true value again it will run do the same process but second time the k value will be 61 because it changes in while condition then after second time condition fail you will get bd is answer
while(k/=16);
printf("%s",trans);

Is This Answer Correct ?    16 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

the portion of a computer program within which the definition of the variable remains unchanged a) mode b) module c) scope d) none

637


What are the advantages and disadvantages of a heap?

697


what will be the output for the following main() { printf("hi" "hello"); }

9302


What is #line?

605


What is the difference between union and anonymous union?

831






Mention four important string handling functions in c languages .

617


When should a type cast be used?

573


What is the right type to use for boolean values in c?

578


What is the difference between procedural and declarative language?

640


What is pointer and structure in c?

561


Tell me is null always defined as 0(zero)?

666


Why do we need a structure?

580


Is a house a mass structure?

635


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1123


Give differences between - new and malloc() , delete and free() ?

601