Multiple choice

What would be the output of the following program? #include<iostream> #include<conio.h> int main() {

int n=5,i,first=0,second=1,third; printf(result ”); printf(“%d %d”,first,second); for(i=2;i<=5;i++) { third=first+second; printf(“%d”,third); first=second; second=third; } getch();

}

  1. 0 1 4 9 16 25

  2. 0 1 1 2 3

  3. 0 1 1 2 3 5

  4. Error in program

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Program will just print Fibonacci numbers as the sum of previous digits in counting up to 5, i.e. 0 1 1 2 3 5. So, option (3) is correct.