Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Object files
*.o
77 changes: 40 additions & 37 deletions Calc.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#include <stdio.h>
#include <stdlib.h>
#include<math.h>
#include <math.h>


float add(float num1, float num2);
Expand All @@ -34,42 +34,45 @@ float divide(float num1, float num2);

int main(void)
{
int choice;
float num[2];
// / A mini dialog we are using to get the user to make a choice
printf("Welcome to the Calculator world\n");
printf("\n Enter The Any Two Number for Calc: ");
scanf("%f%f",&num[0], &num[1]); //These are the numbers we are going to use inside of the calculator

printf("\nEnter your choice:\n");
printf("1. Addition of numbers\n");
printf("2. Multiplication of numbers\n");
printf("3. Subtraction of numbers\n");
printf("4. Division\n");
scanf("%d",&choice);



// This function is going to be used to switch the functions if some aren't used.
switch (choice)
{
case 1:
printf("The sum is %f and %f : %f",num[0],num[1], add(num[0], num[1]));
break;
case 2:
printf("The product is %f and %f : %f",num[0],num[1], multiply(num[0],num[1]));
break;
case 3:
printf("The difference is %f and %f : %f", num[0],num[1],subtract(num[0], num[1]));
break;
case 4:
printf("The Quotient is %f and %f : %f",num[0],num[1], divide(num[0], num[1]));
break;
default:
printf("Wrong choice.");
return 1;

}
printf("Welcome to the Calculator world\n");
while(1) {
int choice;
float num[2];
// / A mini dialog we are using to get the user to make a choice

printf("\n Enter The Any Two Number for Calc: ");
scanf("%f%f",&num[0], &num[1]); //These are the numbers we are going to use inside of the calculator

printf("\nEnter your choice:\n");
printf("1. Addition of numbers\n");
printf("2. Multiplication of numbers\n");
printf("3. Subtraction of numbers\n");
printf("4. Division\n");
scanf("%d",&choice);



// This function is going to be used to switch the functions if some aren't used.
switch (choice)
{
case 1:
printf("The sum is %f and %f : %f\n",num[0],num[1], add(num[0], num[1]));
break;
case 2:
printf("The product is %f and %f : %f\n",num[0],num[1], multiply(num[0],num[1]));
break;
case 3:
printf("The difference is %f and %f : %f\n", num[0],num[1],subtract(num[0], num[1]));
break;
case 4:
printf("The Quotient is %f and %f : %f\n",num[0],num[1], divide(num[0], num[1]));
break;
default:
printf("Wrong choice.");
return 1;

}
}
return 0;

}
Expand Down
Binary file added Calc.exe
Binary file not shown.