Computer Science, asked by shailendrakumar491, 10 months ago

write a program to print the sum of first 10 Fibonacci or the the average of first n natural numbers depending upon user's choice by using methods in Java
plz tell the answer of my question​

Answers

Answered by jennifer639
1

plz mark it brainliest and

follow me

Attachments:
Answered by Anonymous
2

public class Fibonacci

{

 static void Method()

 {

   int a = 0, b = 1, c, x, n = 10;    

   System.out.print ( a + " " + b ); // prints 0 and 1    

    for ( x = 2; x < n; x++ )

    //loop starts with 2 in order to print 2 on-wards now

     {    

        c = a + b;    

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

        a = b;     // swapping the values.  

        b = c;    

     }    

 }

  public static void main(String[] args)

{

   Fibonacci();

 }

}

Similar questions