C Program to Print / Display Fibonacci Series up to N Number using goto statement
C Program to Print / Display Fibonacci Series up to N Number using goto statement
![]() |
C Program to Print / Display Fibonacci Series up to N Number using goto statement |
- //C Program to Print / Display Fibonacci Series upto N Number using if statement
- #include <stdio.h>
- int main() {
- int i=1, n, Number1 = 0, Number2 = 1, next_Number;
- printf("Enter the number to print first N Fibonacci Series:- ");
- scanf("%d", &n);
- printf("Fibonacci Series As Follow :- ");
- Restart:
- if (i <= n)
- {
- printf("%d, ", Number1);
- next_Number = Number1 + Number2;
- Number1 = Number2;
- Number2 = next_Number;
- i++;
- goto Restart;
- }
- return 0;
- }
Output
Test-1
Enter the number to print first N Fibonacci Series:- 10
Fibonacci Series As Follow :- 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,
Test-2
Enter the number to print first N Fibonacci Series:- 20
Fibonacci Series As Follow : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181,
Enter the number to print first N Fibonacci Series:- 10
Fibonacci Series As Follow :- 0, 1, 1, 2, 3, 5, 8, 13, 21, 34,
Test-2
Enter the number to print first N Fibonacci Series:- 20
Fibonacci Series As Follow : 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181,
Comments