Monday 9 September 2024

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

 #include <iostream.h>

#include<conio.h>


// Function to add two numbers

int add(int x, int y) 

{

    return x + y;

}

int main()

 {

    int num1, num2, result;


    // Input values

    cout << "Enter the first number: ";

    cin >> num1;

    cout << "Enter the second number: ";

    cin >> num2;


    // Call the add function and store the result

    result = add(num1, num2);


    // Display the result

    cout << result;

    getch();

    return 0;

}