how to convert this C++ code to Turbo C?

夙愿已清 提交于 2019-12-13 08:57:06

问题


C++ code:

cout << "Roots are complex and different."  << endl;
cout << "x1 = " << realPart << "+" << imaginaryPart << "i" << endl;
cout << "x2 = " << realPart << "-" << imaginaryPart << "i" << endl;

How can I convert this to Turbo C like printf instead of cout?


回答1:


May be you are seeking for this:

printf("Roots are complex and different.\n");
printf("x1 = %lf+%lfi\n",realPart,imaginaryPart);
printf("x2 = %lf-%lfi\n",realPart,imaginaryPart);

if realPart and imaginaryPart variables are in data type double.

Use %f for float, %d for int, %s for string instead of %lf in the code otherwise.



来源:https://stackoverflow.com/questions/32664533/how-to-convert-this-c-code-to-turbo-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!