!!!!!!!!!!!!!!!!!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
HERE IS THE SCREENSHOT OF OUTPUT
PLEASE DO UPVOTE IT MOTIVATES US TO DO BETTER.FEEL FREE TO REACH US IN THE COMMENT FOR ANY QUERY OR DOUBT.BE SAFE
QUESTION 26 Given the following function: int secret(int num, int m) inti, prod=1; if (m=0) return...
What is the output of the following C++ code? int count = 1; int num = 25; while (count < 25) { num--; count++; } cout << count « " " « num << endl i 25 1 0 24 1 0 25 0 0 24 0 In this while loop statement, while (counter < 10), where counter is an int variable. Which statement below is an equivalent way to write this while statement? while (10 < counter) while (9...
1) Fix the Function #include <iostream> void print Num() { std::cout << number; }; int main() { int number = 35; printNum (number); return 0; (Give two ways to fix this code. Indicate which is preferable and why.) #include <iostream> void double Number (int num) {num = num * 2;} int main() { int num = 35; double Number (num); std::cout << num; // Should print 70 return 0; (Changing the return type of doubleNumber is not a valid solution.)
Write the output of the following function assuming it was called with the given function call a. Call: fun(4, 10); fo void fun (int a, int b) cout << b a << endl; if(a >= b) { 나 cout < "boo\n"; return; fun(a 1, b 1); cout << a << endl;
(a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...
Problem 1. Select the running time of each function. void print_array (int* A, int n) for (int í 0; i < n; ++i) cout << A[i] << endl; void print_array pairs (int* A, int n) for (inti 0; i < n; ++i) for (int j 0; j < n; ++j) cout << Ai] ALj]< endl; void print_array_start(int* A, int n) for (int i 0; i < 100 ; ++i) cout << A[i] << endl; void print_array_alt (int* A, int n)...
This is for C in Linux: Problem 1: Given the following recursive function: void recursiveFunction( int m ) printf("%d", m); if( m <= 0 ) return; if( n + 2 == 0 ) recursiveFunction( m - 1); else recursiveFunction( m - 2); What is the output when the following functions are called with these parameters? recursiveFunction( 5 ); recursiveFunction( 10 ); recursiveFunction( 0);
* The output of the following code is #include <iostream> using namespace std: int prod (int x, int y=3){ int d; int a=x*y; return (a); int main ({ cout << prod (7) <<" "<<prod (6, 4); return 0; 21 12 O 49 24 O 21 24 O 21 18
All in C++ Create a function NumEven( std: forward_list-int> SList) that computes and returns the number of even values in a singly linked list SList of type std: forward_list-int> If there is no even value or the list is empty, return 0. Select the appropriate C++ statement for each of the below to implement the function. unsigned NumEven (std:: forward_list<int> Slist) { Select] Select ] Select ] } [ Select] for (int i; i < num; i++) { if (n...
start solve 6,8 int test function return value solve (int a, int b) 12,3 int average-a. b)/2 solve ng flow chart? int value average int test2 function return value cout << (testi test2] << endl value end cout << (test1 - test2] << endl value end False True (a + b) % value=0 True False value value.
6) What is the final value of variable num after executing the following statements? void Exam(int & N) A)13 ( T++ ¢ut << < 1 ) B)12 void main() (int num-10; C) 11 for (int i - 0; i < 3; i.) Exam (num). D) 10