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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
