Computer Science, asked by Ronney123, 10 months ago

???????????????PLZ ANSWER FAST ????????????? And quickly................

Attachments:

Answers

Answered by ShadowAmitendu
1

Answer:

In C

Explanation:

#include <stdio.h>

int main() {

int i, n, t1 = 0, t2 = 1, nextTerm;

printf("Enter the number of terms: ");

scanf("%d", &n);

printf("Fibonacci Series: ");

for (i = 1; i <= n; ++i) {

printf("%d, ", t1);

nextTerm = t1 + t2;

t1 = t2;

t2 = nextTerm;

}

return 0;

}

In Java

public class Fibonacci {

public static void main(String[] args) {

int n = 10, t1 = 0, t2 = 1;

System.out.print("First " + n + " terms: ");

for (int i = 1; i <= n; ++i)

{

System.out.print(t1 + " + ");

int sum = t1 + t2;

t1 = t2;

t2 = sum;

}

}

}

Similar questions