Computer Science, asked by sitacsumanpeeyjv, 11 months ago

0,1,1,2,3,5,8,13............n terms

Write this program by using switch case to print it

Answers

Answered by Siddharta7
3

Explanation:

#include <stdio.h>

int fibonacci(int num);

int main(int argc, char const *argv[]) {

int choice;

int num;

int sequence;

printf("1) Calculate Fibonacci\n");

printf("2) Exit\n");

scanf("%d", &choice);

if (choice == 1)  

{

  do  

  {

    printf("Input integer n :\n");

    scanf("%d", &num);

    if (num < 0)  

    {

      printf("n should be a positive integer (n >= 1). Retry\n");

    }

  } while (num < 0);

}

if (choice == 1 && num > 0)  

{

  printf("Fibonacci sequence of %d terms\n", num);

Hope it helps!

Similar questions