0
#include<iostream>
#include <iomanip>
using namespace std;
int main()
{
 float radius, area, circumference, diameter;
const double pi = 3.14159265358979323846;
 cout << "\n Please Enter the radius of a circle : ";
cin >> radius;
  diameter = 2 * radius;
  circumference = 2 * pi * radius;
  area = pi * radius * radius; 
 cout << ("\n\t  Diameter Of a Circle ", diameter);
 cout << ("\n\t Circumference Of a Circle ", circumference);
 cout << ("\n\t Area Of a Circle", area);

 return 0;
}

Trying to get the three outputs from the last three couts ( Diameter, circumference and Area) , but only get a random number, 1443.9823153.938. Can anyone identify what I am doing wrong or what I'm missing?

John Kugelman
  • 349,597
  • 67
  • 533
  • 578
  • 4
    Double check the syntax of `cout`. It doesn't use parentheses or commas like this. – John Kugelman Sep 06 '22 at 02:32
  • 1
    `cout << ("\n\t Diameter Of a Circle ", diameter);` should be `cout << "\n\t Diameter Of a Circle " << diameter;` – Borgleader Sep 06 '22 at 02:33
  • The "random number" in this case will be all 3 values concatenated together. It would appear from your output that you gave the input "7". When you find your program behaves unexpectedly, don't be afraid of modifying it to see what's going on. You could comment-out all but one of those `cout` statements and discover that indeed they each output something predictable. Then, your question would become about something else entirely. – paddy Sep 06 '22 at 02:33
  • Pedantic note: call it an unexpected number. There's not much that's actually random in computing. – user4581301 Sep 06 '22 at 02:35

0 Answers0