Advertisements
Advertisements
प्रश्न
What is the output of the program code given below, when the value of x = 294?
int simple(int x)
{return (x<=0)? 0: x + simple(x/10);}अति संक्षिप्त उत्तर
Advertisements
उत्तर
325
Explanation:
The statement:
return ((x<=0)?0:x+simple(x/10)); performs itself recursively using x/10.
Hence the processing of x + simple(x/10) is calculated as 294 + 29 = 325.
shaalaa.com
या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
