Question

QUESTION 26 Given the following function: int secret(int num, int m) inti, prod=1; if (m=0) return 1: - for (i=0; i<m; i++) {
0 0
Add a comment Improve this question Transcribed image text
Answer #1

!!!!!!!!!!!!!!!!!PLEASE DO UPVOTE!!!!!!!!!!!!!!!

<<<<<<<<<<MIND THE INDENTATION>>>>>>>>>>>>>>>>>

#include <iostream> using namespace std; int secret(int num,int m) { int i, prod = 1; if (m==0) return 1; for (i=0;i<m;i++) {prod= prod*num;} return prod; } int main() { cout<<secret(10,6); return 0; } 

In then above code we run a function secret and pass 10 and 6 in it then the code further goes into the loop in which loop run from i =0 to 5. The initial value of prod is 1 then

1x10=0

10x10=100

.

.

.

100000 x 10 =1000000

then we return

here is the screenshot of input code

main.cpp (udemy) - Code:Blocks 17.12 <global main : int Debug ***< | 2 9 main.cpp X Files Management < Projects Symbols WorksHERE IS THE SCREENSHOT OF OUTPUT

main.cpp (udemy) - Code:Blocks 17.12 File Edit View Search Project Build Debug Fortran wxSmith Tools Tools+ Plugins DoxyBlock

PLEASE DO UPVOTE IT MOTIVATES US TO DO BETTER.FEEL FREE TO REACH US IN THE COMMENT FOR ANY QUERY OR DOUBT.BE SAFE

Add a comment
Know the answer?
Add Answer to:
QUESTION 26 Given the following function: int secret(int num, int m) inti, prod=1; if (m=0) return...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT