Solve Me #2

Pasindu want to make an app to find the positive square root of real numbers. So help him to do.
You can use any programming language to complete this task.
You can't exceed the range of inputs given.
You have to print negatives and positives separately.
Happy Coding..!


SAMPLE INPUTS:
255 144 -0.25 -25 0.5 -163

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. #include
    #include
    #include
    #include
    using namespace std;
    double squareroot (double x){
    return sqrt(x);
    }
    int main()
    {
    double num;
    do{
    cin>>num;
    if(num<0){
    num= -num;
    double y = squareroot(num);
    cout<<"square root:"<<y<<"i"<<endl;//i=sqrt(-1);
    }
    else{
    double z = squareroot(num);
    cout<<"square root:"<<z<<endl;
    }
    }
    while(num !=0);
    return 0;
    }

    ReplyDelete
    Replies
    1. Really i do not know how to find square root of negative numbers, but i have read that i=square root (-1)

      Delete
    2. Square roots of negative numbers are imaginary numbers

      Delete

Post a Comment