#include<iostream>
using namespace std;
unsigned long factorial( unsigned long );
unsigned long fibonacci(unsigned long );
int main(){
unsigned long size_factorial,size_fibonacci,result;
cout<<"input an unsigned integer for thr upper bound of factorial() "<<endl;
cin>>size_factorial;
cout<<"input an unsigned integer for thr upper bound of fibonacci() "<<endl;
cin>>size_fibonacci;
cout<<"the result of factorial(size_factorial) is: "<<factorial(size_factorial)<<endl;
cout<<"the result of fibonacci(size_fibonacci) is: "<<fibonacci(size_fibonacci)<<endl;
cout<<"the sum of factorial(size_factorial) and fibonacci(size_fibonacci) is ";
result=factorial(size_factorial)+fibonacci(size_fibonacci);
printf("%lu",result);
return 0;
}
unsigned long factorial( unsigned long number ) {
if ( number <= 1 ) { return 1 ; }
else {
return ( number * factorial( number - 1 ) );
}
}
unsigned long fibonacci(unsigned long number){
unsigned long a=0,b=1,c=1;
if(number==0){
return a;
}
for(unsigned long i=1;i<=number;i++){
c=a+b;
a=b;
b=c;
}
return b;
}

Please help asap Q6 6" (15%) Fill up the missing bodies of factorialO and fibonacciO of...
****I'm trying to compile this code, however, the answer still shows "0". This the formula I'm trying to use: (num1!) / ((num2!)(num1 - num2)! ) ***** (C++) FOR INSTANCE; Big Number = 20 and Small Number = 3 #include <iostream> using namespace std; int factorial(int num1, int num2){ unsigned long long answer = 0; unsigned long long top = 1; unsigned long long bottom = 1; unsigned long long bottom2 = 1; unsigned long long bottom_3 = 1; int num3...
Need help coding this program and please explain how the
operations work in pseudocode please.
Problem: Starting with the following C++ program #include <iostream> using namespace std; void main () long Var16; long Var210; long var3 = 15; long Var4 21; long Var522; long Sum; long Result; long Remainder; const unsigned byte c-6: const unsigned byte c2-10; const unsigned byte c3-15 const unsigned byte c4 21; const unsigned byte c5 22; a sm cout << "Sum is cout << "Result...
This is a fill in the code type: // FILL IN THE CODE - Write a program to multiply 2 numbers, print out the results and print out the original numbers in ascending order. #include <iostream> using namespace std; int main() { int num1; // holds 1st number int num2; // holds 2nd number int result; // holds result of multiplication int *num1Ptr = nullptr; // int pointer which will be set to point to the 1st number int *num2Ptr...
Create a program with the main function and one additional function. The additional function asks for input from the user and returns the output back to the main function for display. This is for c++ and here is my code, could you guys please tell me what I am missing from the instructions. Thank you #include <iostream> using namespace std; int sum (int, int); int main() { int n1, n2, total; cout << "Enter two numbers...
Who could write the array.cpp file ? //main.cpp #include "array.hpp" #include <iostream> int main() { int n; std::cin >> n; array a(n); for (int i = 0; i < n; i++) { std::cin >> a.data()[i]; } std::cout << "array size:" << a.max_size() << std::endl; std::cout << "array front:" << a.front() << std::endl; std::cout << "array back:" << a.back() << std::endl; int* data = a.data(); std::cout << "array elements using data:" << std::endl; for (int i = 0; i < n;...
When I input 210 or 110 or 340 it always returns 0 instead of 3 or 2 or 7. Why isn't it adding the sum of all the numbers? #include <iostream> using namespace std; int main() { long num; cout << "Input a number: "; cin >> num; int n = 0; while (num != 0) { n += num % 10; num = num / 10; } if (num...
Having to repost this as the last answer wasn't functional. Please help In the following program written in C++, I am having an issue that I cannot get the reducdedForm function in the Rational.cpp file to work. I cant figure out how to get this to work correctly, so the program will take what a user enters for fractions, and does the appropriate arithmetic to the two fractions and simplifies the answer. Rational.h class Rational { private: int num; int...
c++
Some pieces of the following code are missing. Fill in the blanks of the following program. Each answer must fit on a single line. include <iostream> #include <cstdib #include <ctimes using namespace std; randoml_event return 2 (rand() 5 random2 intre + rand 90 return ret: random1_1000X rand) intret 100 return ret: fint 2) return nt; return n2 is oder Is_odot if (n%2 0) return return true; int sum3 (int n, int n, int n3 X int sum= n1 +...
I am having trouble figuring out why my program will not make any columns, just rows. I need to display a square. The instructions are provided below. (This for my C++ class) Write a program that displays a square. Ask the user for the square’s size. Only accept positive integer numbers (meaning choose a data type that holds positive integer values). The size the user gives you will determine the length and width of the square. The program should then...