Question

8. Given the following code fragment and function definition, what is(are) the output(s)? int funct (int n) int var = 1; whil

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// Screenshot of the code

// Sample output

// Code to copy

#include<iostream>
using namespace std;

int funct(int);

int main()
{  
cout << funct(7)<<" "<<funct(0);
   return 0;
}

int funct(int n){
   int var=1;
   while(n>0){
       var*=n;
       n--;
   }
   return var;
}

Explanation:

if n=7 the above code prints 7! value as 5040.

7!=7*6*5*4*3*2*1

Add a comment
Know the answer?
Add Answer to:
8. Given the following code fragment and function definition, what is(are) the output(s)? int funct (int...
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