American Airlines interview question

Write pseudo code to print out the Fibonacci sequence.

Interview Answers

Anonymous

Nov 11, 2014

Hello, Can you please help me give more details of the interview please. It will be a lot helpful for me. Thanks alot in advance. Swetha

3

Anonymous

Oct 21, 2015

#include using namespace std; int main() { int n, c, next; int first = 1; int second = 1; cout > n; if ((n == 1) || (n == 2)) { if (n == 1) cout << "1" << endl; if (n == 2) cout << "1 1" << endl; } else { cout << "1 1 "; for (c = 3; c <= n; c++) { next = first + second; cout << next << " "; first = second; second = next; } cout << endl; } return 0; }