Find the output of the following program including time and space complexity. #include<iostream> int main(){ int n; std::cout <<"Enter the number of…
Find the output of the following program including time and space complexity.
#include<iostream>
int main(){
int n;
std::cout <<"Enter the number of terms for the fiboncci series: ";
std::cin >> n;
int first = 0, second =1;
if(n>=1){
std::cout <<"Fibonacci Series:"<< first;
if(n>=2){
std::cout<< second;
}
for(int i=2;i<n ;i++){
int next = first + second;
std::cout<<","<<next;
first = second;
second = next;
}
}
std::cout<<std::endl;
return 0;
}From the Rupali Bank Assistant Network Engineer November 2023 – Written (MIST) exam, question 21 of 22.