Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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);
}

Answers were Sorted based on User's Feedback



main() { unsigned int k = 987 , i = 0; char trans[10]; do { trans[i++] =(char) (k%16 > 9 ? k..

Answer / 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

main() { unsigned int k = 987 , i = 0; char trans[10]; do { trans[i++] =(char) (k%16 > 9 ? k..

Answer / deepthisivan

bd

Is This Answer Correct ?    13 Yes 0 No

main() { unsigned int k = 987 , i = 0; char trans[10]; do { trans[i++] =(char) (k%16 > 9 ? k..

Answer / 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

main() { unsigned int k = 987 , i = 0; char trans[10]; do { trans[i++] =(char) (k%16 > 9 ? k..

Answer / dishank

deepthisivan can u plz elaborate.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Interview Questions

the number of measuring units from a arbitrary starting point in a record area or control block to some other point a) branching b) recording pointer c) none d) offset

0 Answers  


What are the different file extensions involved when programming in C?

0 Answers  


What is meant by preprocessor in c?

0 Answers  


What is header file definition?

0 Answers  


What are the different types of linkage exist in c?

0 Answers  


write a program that will read the temperature in Celsius and convert that into Fahrenheit.

1 Answers  


What are the parts of c program?

0 Answers  


What is strcmp in c?

0 Answers  


what are advantages of U D F?

1 Answers   Google,


write a c program to find the sum of five entered numbers using an array named number

0 Answers   TATA,


Which of the Following is not defined in string.h? A)strspn() B)strerror() C)memchr() D)strod()

2 Answers   Accenture, TCS,


What is fflush() function?

0 Answers  


Categories