C# Programming - Control Instructions - Discussion

Discussion Forum : Control Instructions - General Questions (Q.No. 11)
11.
The C#.NET code snippet given below generates ____ numbers series as output?
int i = 1, j = 1, val;
while (i < 25)
{
    Console.Write(j + " ");
    val = i + j;
    j = i;
    i = val;
}
Prime
Fibonacci
Palindrome
Odd
Even
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
1 comments Page 1 of 1.

Sajila said:   1 decade ago
First print j=1
val=1+1=2
j=1
i=2
Print j=1

val=1+2=3
j=2
i=3
Print j=2

val=2+3=5
j=3
i=5
Print j= 3

val=5+3=8
j=5
i=8
Print j=5

val=8+5=13
j=8
i=13
Print j=8

val=8+13=21
j=13
i=21
Print j=13

val=13+21=34
j=21
i=34
Now i>25
Then exit

Output is: 1 1 2 3 5 8 13 21 .
(1)

Post your comments here:

Your comments will be displayed after verification.