2 votes 2 votes What will be output of the program? int d=0; int f(int a,int b){ int c; d++; if(b==3) return a*a*a; else{ c=f(a,b/3); return(c*c*c); } } int main(){ printf("%d",f(4,81)); return 0; } Programming in C programming-in-c + – srestha asked Mar 5, 2019 srestha 1.2k views answer comment Share Follow See all 27 Comments See all 27 27 Comments reply karan25gupta commented Mar 5, 2019 i moved by Shaik Masthan Mar 5, 2019 reply Follow Share is answer= 4^27 ? 0 votes 0 votes Shaik Masthan commented Mar 5, 2019 reply Follow Share f(a,b) = a^b where b is multiple of 3 0 votes 0 votes Chaitrasj commented Mar 5, 2019 i edited by Chaitrasj Mar 5, 2019 reply Follow Share I think the code will give $4^{81}$ as output. 1 votes 1 votes srestha commented Mar 5, 2019 reply Follow Share @Chaitrasj that mean whenever int in not range, it will give 0? Say for int 2 B, range -32768 to 32768 , then it will print 0 but for int 4 B, range -2147483648 to 2147483648 can it be in range? 0 votes 0 votes Shaik Masthan commented Mar 5, 2019 reply Follow Share if you take the result as int, then end result is compiler implementation defined, don't worry about it ! if you want the exact result then use long long int !! 1 votes 1 votes srestha commented Mar 5, 2019 reply Follow Share ok, but why output will 0 why not garbage value or will not take unsigned type value? I mean when out of range, why not rotating the value from first again? 0 votes 0 votes Chaitrasj commented Mar 5, 2019 reply Follow Share Yes @srestha maam, it won't be 0, i will edit my comment. I think it will wrap around or maybe it is compiler dependent. 0 votes 0 votes srestha commented Mar 5, 2019 reply Follow Share Ans giving 0 but here showing no output https://ideone.com/TrEwWm Confusing me badly :( 0 votes 0 votes Shaik Masthan commented Mar 5, 2019 reply Follow Share it is showing.... you have to notice ! Forget about the o/p, it's useless to think !! Moreover try the C codes on OFFLINE instead of ONLINE !!! PS :- if you want to check in online, then use tutorials, codechef or joodle is better than ideone, it's my opinion 0 votes 0 votes srestha commented Mar 5, 2019 reply Follow Share Forget about the o/p, it's useless to think !! why? Moreover try the C codes on OFFLINE instead of ONLINE !!! u mean in pen and paper? then use tutorials which tutorial? 0 votes 0 votes harsh.preet commented Mar 6, 2019 i moved by Shaik Masthan Mar 6, 2019 reply Follow Share Its 4^81 i think.. 0 votes 0 votes Shaik Masthan commented Mar 6, 2019 reply Follow Share u mean in pen and paper? no.. offline compiler, i.e., the one which is installed by you in your PC. which tutorial? Tutorials website online compiler, https://www.tutorialspoint.com/compile_c_online.php Forget about the o/p, it's useless to think !! why? due to you understood the concept behind the function f(). 0 votes 0 votes srestha commented Mar 6, 2019 reply Follow Share Actually every compititive exam concern about output. and if output is wrong, we get -ve marks Do u think, this question will not come and I donot get any difference between online and offline compiler. Do u get any difference? 0 votes 0 votes Shaik Masthan commented Mar 6, 2019 reply Follow Share Do u think, this question will not come that question is not correct, due to out of range ! if it is a standard question, then think about exact output !! Moreover most of the ACE test series questions are dilute our concept ( it's my opinion ) and I do not get any difference between online and offline compiler. Do u get any difference? some of the questions you will get the differences. 0 votes 0 votes srestha commented Mar 6, 2019 reply Follow Share @Shaik Masthan then what do u tell about this year GATE paper? It was not easy, but still someone got 88 which concept need and where it is need, u totally need to examine. I just do that examine on every question 0 votes 0 votes Shaik Masthan commented Mar 6, 2019 reply Follow Share mam, didn't get your comment completely ! 0 votes 0 votes srestha commented Mar 6, 2019 reply Follow Share Moreover most of the ACE test series questions are dilute our concept ( it's my opinion ) I mean , each question has a concept(may be question right or wrong) I enrich by that concept only 0 votes 0 votes Shaik Masthan commented Mar 6, 2019 reply Follow Share then you didn't get the concept behind this question ? 0 votes 0 votes srestha commented Mar 6, 2019 reply Follow Share no, when I put this question, not getting why ans is 0 but now I get that if this question in some standard exam, then we can even challenge it right? 0 votes 0 votes srestha commented Mar 6, 2019 reply Follow Share And I was thinking of wrap abound concept But now I think , wraparound is operated only for unsigned int 0 votes 0 votes Kaluti commented May 22, 2019 reply Follow Share Can someone answer what would be answer if we will apply wraparound concept here assuming it to be unsigned int 0 votes 0 votes srestha commented May 23, 2019 reply Follow Share @Kaluti wraparound means , in the signed integer, if the range completes then it again goes from first right?? 0 votes 0 votes srestha commented May 23, 2019 reply Follow Share without wrap around it will be $4^{36}$ rt?? 0 votes 0 votes Kaluti commented May 23, 2019 reply Follow Share Mam without wraparound $4^{81}$ and with wraparound how will be $4^{36}$ 0 votes 0 votes srestha commented May 23, 2019 reply Follow Share how $4^{81}??$ 0 votes 0 votes Kaluti commented May 23, 2019 reply Follow Share Mam I wanna ask how without wraparound u are getting $4^{36}$ 0 votes 0 votes srestha commented May 23, 2019 reply Follow Share just simply run code in pen and paper 0 votes 0 votes Please log in or register to add a comment.