Program to find Fibonacci Series, Factorial or Multiplication Table of a number as per user's choice.
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void fibonacci ();
void factorial ();
void multiplication ();
void main()
{
int b, c;
clrscr();
printf ("Enter your choice: ");
printf ("\n1. Find the Fibonacci Series upto the number.");
printf ("\n2. Find the Factorial of a number.");
printf ("\n3. Find the Multiplication Table of a number.");
printf ("\n4. Exit\n");
scanf ("%d", &b);
switch (b)
{
case 1: fibonacci ();
break;
case 2: factorial ();
break;
case 3: multiplication ();
break;
case 4: exit (0);
break;
default:
printf ("Enter the correct option.");
}
getch();
}
void fibonacci ()
{
int a, w, x= 0, y= 1, z;
printf ("Enter a positive integer: ");
scanf ("%d", &a);
printf ("The Fibonacci Series is: ");
for ( w=1; w<=a; ++w)
{
printf ("%d\t", x);
z = x + y;
x = y;
y = z;
}
}
void factorial ()
{
int a, n, num= 1;
printf ("Enter a positive integer: ");
scanf ("%d", &a);
for (n=1; n<=a; n++)
{
num = num * n;
}
printf ("The Factorial is: %d", num);
}
void multiplication ()
{
int a, m;
printf ("Enter a positive integer: ");
scanf ("%d", &a);
printf ("The multiplication table is: ");
for (m=1; m<=10; m++)
{
printf ("\n%d * %d = %d", a, m, a*m);
}
}
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
void fibonacci ();
void factorial ();
void multiplication ();
void main()
{
int b, c;
clrscr();
printf ("Enter your choice: ");
printf ("\n1. Find the Fibonacci Series upto the number.");
printf ("\n2. Find the Factorial of a number.");
printf ("\n3. Find the Multiplication Table of a number.");
printf ("\n4. Exit\n");
scanf ("%d", &b);
switch (b)
{
case 1: fibonacci ();
break;
case 2: factorial ();
break;
case 3: multiplication ();
break;
case 4: exit (0);
break;
default:
printf ("Enter the correct option.");
}
getch();
}
void fibonacci ()
{
int a, w, x= 0, y= 1, z;
printf ("Enter a positive integer: ");
scanf ("%d", &a);
printf ("The Fibonacci Series is: ");
for ( w=1; w<=a; ++w)
{
printf ("%d\t", x);
z = x + y;
x = y;
y = z;
}
}
void factorial ()
{
int a, n, num= 1;
printf ("Enter a positive integer: ");
scanf ("%d", &a);
for (n=1; n<=a; n++)
{
num = num * n;
}
printf ("The Factorial is: %d", num);
}
void multiplication ()
{
int a, m;
printf ("Enter a positive integer: ");
scanf ("%d", &a);
printf ("The multiplication table is: ");
for (m=1; m<=10; m++)
{
printf ("\n%d * %d = %d", a, m, a*m);
}
}