Dremendo Tag Line

Input 2 integers and print the sum of their square roots using mathematical functions in C++

Mathematical Functions - Question 2

In this question, we will see how to input two integer numbers and print the sum of their square roots in C++ programming using the mathematical functions. To know more about mathematical functions click on the mathematical functions lesson.

Q2) Write a program in C++ to input two integer numbers and print the sum of their square roots using the sqrt() function.

Program

#include <iostream>
#include <conio.h>
#include <cmath>

using namespace std;

int main()
{
    int a,b;
    double s;
    cout<<"Enter 2 integer numbers\n";
    cin>>a>>b;
    s=sqrt(a) + sqrt(b);
    cout<<"Sum of the square root = "<<s;
    return 0;
}

Output

Enter 2 integer numbers
25
9
Sum of the square root = 8
video-poster