Saturday, 28 September 2024

Write a program to calculate addition ,subtraction ,multiplication,division using function.

 

#include <stdio.h>


// Function to add two numbers

int addition(int num1, int num2) {

    return num1 + num2;

}


int main() {

    int number1, number2, sum;


    // Taking input from user

    printf("Enter first number: ");

    scanf("%d", &number1);

    printf("Enter second number: ");

    scanf("%d", &number2);


    // Calling the addition function

    sum = addition(number1, number2);


    // Displaying the result

    printf("The sum %d %d %d", number1, number2, sum);


    return 0;

}