Professional Documents
Culture Documents
h>
#include <stdlib.h>
int main()
{
int choice_num, repick;
do
{
printf("Select from the following options the calculation you wish to
execute.\n");
printf("Please enter your choice:");
scanf("%d",&choice_num);
printf("\n");
switch (choice_num)
{
case 1:
{
double first_num, second_num, sum, difference, product,
quotient;
printf("This is a program that perform basic
calculation.\n");
printf("Please enter the first number:");
scanf("%lf", &first_num);
printf("Please enter the second number:");
scanf("%lf", &second_num);
sum = first_num+second_num;
difference = first_num-second_num;
product = first_num*second_num;
printf("\n");
printf("Results:\n");
printf("Sum = %lf \n", sum);
printf("Difference = %lf \n", difference);
printf("Product = %lf \n", product);
if (second_num == 0)
printf("Quotient is Undefined. Division of Zero is not
allowed.\n\n");
else
{
quotient = first_num/second_num;
printf("Quotient = %lf \n\n", quotient);
}
}
break;
case 2:
{
int i, n, t1 = 0, t2 = 1, next_term;
printf("This is a program that print Fibonacci series.\n");
printf("Enter the number of terms:");
scanf("%d", &n);
printf("Fibonacci Series:");
}
break;
default:
printf("Please re-enter your choice again.\n\n");
break;
}
printf("If you wish to perform again,\n");
printf("Press 1 if Yes\n");
printf("Press 2 if No\n");
printf("Answer:");
scanf("%d",&repick);
printf("\n");
}
printf("End of Program.\n");
printf("Bye!");
return 0;
}