Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
238 views
Welcome To Ask or Share your Answers For Others

1 Answer

May be you are seeking for this:

printf("Roots are complex and different.
");
printf("x1 = %lf+%lfi
",realPart,imaginaryPart);
printf("x2 = %lf-%lfi
",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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...