|
|
back to boardHelp what is wrong? C++ Posted by Misha 25 Jan 2015 15:09 This is my code. #include <iostream> #include <cmath> #include <iomanip> using namespace std; int main() { long double a; cin >> a; cout << fixed << setprecision(4) << sqrt(a) << endl; return 0; } Re: Help what is wrong? C++ In my opinion the problem is that the user should be able to insert a set of numbers, while in your code you can only give 1 value in input. Re: Help what is wrong? C++ Posted by dream 23 Mar 2015 12:49 as i known you can insert the code "main()" on the line of "return 0;" Re: Help what is wrong? C++ the wrong is your data type try to store the double side alone and the integar alone and then calculate them into output :D like long long int_side = sqrt(a); double float_side = sqrt(a)-int_side; cout << int_side+float_side ; Re: Help what is wrong? C++ You also have to print result in reverse order. Square root of number you read last should be displayed first. Edited by author 26.05.2015 19:16 Edited by author 26.05.2015 19:16 |
|
|