# WAP in C to Built Mini Calculator using function!

The Program in C to Built Mini Calculator using function is given below:

``````#include <stdio.h>

int add(int a, int b) {
return a + b;
}

// Function for subtraction
int subtract(int a, int b) {
return a - b;
}

// Function for multiplication
int multiply(int a, int b) {
return a * b;
}

// Function for division
float divide(int a, int b) {
return (float)a / b;
}

int main() {
int choice, a, b;
float result;

printf("2. Subtraction\n");
printf("3. Multiplication\n");
printf("4. Division\n");
scanf("%d", &choice);

printf("Enter two numbers: ");
scanf("%d%d", &a, &b);

switch(choice) {
case 1:
printf("Result: %d\n", result);
break;
case 2:
result = subtract(a, b);
printf("Result: %d\n", result);
break;
case 3:
result = multiply(a, b);
printf("Result: %d\n", result);
break;
case 4:
result = divide(a, b);
printf("Result: %.2f\n", result);
break;
default:
printf("Invalid choice.\n");
}

return 0;
}
``````

## Output:

2. Subtraction
3. Multiplication
4. Division
Enter two numbers: 5
6
Result: 6

## Pro-Tips💡

This program allows the user to select an operation (addition, subtraction, multiplication, or division) and then enter two numbers.

The corresponding function is called and the result is displayed.

### Learn C-Sharp ↗

C-sharp covers every topic to learn about C-Sharp thoroughly.

### Learn C Programming ↗

C-Programming covers every topic to learn about C-Sharp thoroughly.

### Learn C++ Programming↗

C++ covers every topic to learn about C-Sharp thoroughly.

Codeauri is Code Learning Hub and Community for every Coder to learn Coding by navigating Structurally from Basic Programming to Front-End Development, Back-End Development to Database, and many more.

## C# Program to Find Sum of Rows & Columns of a Matrix

The Program in C# Program to Find Sum of Rows & Columns of a Matrix is given below: Output: Hello Codeauri Family,enter the number of rows and columns…

## C# Program to Calculate Determinant of Given Matrix

The Program in C# Program to Calculate Determinant of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns of the matrix…

## C# Program to Find Sum of right Diagonals of a Matrix

The Program in C# Program to Find Sum of right Diagonals of a Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns…

## C# Program to Find Transpose of Given Matrix

The Program in C# Program to Find Transpose of Given Matrix is given below: Output: Hello Codeauri Family, enter the number of rows and columns in the matrix:22Enter…

## C# Program for Multiplication of two square Matrices

The Program in C# Program for Multiplication of two square Matrices is given below: Output: Hello Codeauri Family, enter the number of rows/columns in the matrices:2Enter the elements…

## C# Program to Delete Element at Desired position From Array

The Program in C# Program to Delete Element at Desired position From Array is given below: Output: Hello Codeauri Family, enter the number of elements in the array:4Enter…

Your Journey into Code Begins Now: Discover the Wonders of Basic Programming

X