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...

what will be printed by this printf?
printf("%c",printf("hi")["sharkselva"]));
}

Answer Posted / vadivelt

Ans: hia

Reason is, in the below statement,
printf("%c",printf("hi")["sharkselva"]));

printf("hi") shall be executed first. and this printf will
return the value 2. ie., no of characters successfully
printed by printf()statement.

So in runtime, "printf("%c",printf("hi")["sharkselva"]));"
will print "hi" and after, the main printf shall be
replaced as "printf("%c",2["sharkselva"]));".

According to printf() implementation, printf("%c",2
["sharkselva"]));" has to print the value at the array, for
the index given ie., 2. So in the array index '2',
character 'a' is available.

Now a is printed.

So the total output will be -> hia

Is This Answer Correct ?    31 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what are bit fields? What is the use of bit fields in a structure declaration?

2045


Why string is used in c?

954


Are the variables argc and argv are local to main?

1252


What is use of null pointer in c?

959


Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

1034


Explain the difference between malloc() and calloc() function?

988


Where local variables are stored in c?

957


Are there any problems with performing mathematical operations on different variable types?

992


What is difference between function overloading and operator overloading?

1046


List the difference between a While & Do While loops?

1052


In a header file whether functions are declared or defined?

1078


Write a program to use switch statement.

1077


Does * p ++ increment p or what it points to?

1055


Explain which of the following operators is incorrect and why? ( >=, <=, <>, ==)

977


Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol

1075