Results 1 to 11 of 11

Thread: Code check please

  1. #1
    Aerials
    Guest

    Question Code check please

    I'm trying to make a prog that finds the area of a circle.
    After asking the user the radius of the circle it should display the area after a calculation.
    But the program wont display the final result. Why?
    Code:
    #include <iostream.h>
    #include <conio.h>
    
    int main()
    {
    int radius;
    const double pi=3.14;
    cout<<"Find the area of a circle!\n";
    cout<<"Enter the radius of the circle you want to find the radius of(Works best with whole numbers): ";
    cin>>radius;
    cout<<"The area is: "<<(radius*pi);
    getch();
    return 0;
    }
    I'd appreciate if I could get help ASAP

  2. #2
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    PHP Code:
    #include <iostream.h>
    #include <conio.h>

    int main()
    {
    int radius;
    const 
    double pi=3.14;
    cout << "Find the area of a circle!" << endl;
    cout << "Enter the radius of the circle you want to find the radius of(Works best with whole numbers): ";
    cin>>radius;
    cout << "The area is: "<< (radius*pi) << endl;
    getch();
    return 
    0;

    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  3. #3
    Aerials
    Guest
    thx

  4. #4
    Frenzied Member Technocrat's Avatar
    Join Date
    Jan 2000
    Location
    I live in the 1s and 0s of everyones data streams
    Posts
    1,024
    Sure
    Just remember to tell the iostream that you are done with a line from now on and you should be ok.
    MSVS 6, .NET & .NET 2003 Pro
    I HATE MSDN with .NET & .NET 2003!!!

    Check out my sites:
    http://www.filthyhands.com
    http://www.techno-coding.com


  5. #5
    Aerials
    Guest

  6. #6
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    endl does not only start a new line but also flushes the ouput buffer, so things are actually written to the screen.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  7. #7
    Fanatic Member
    Join Date
    Sep 2000
    Location
    UK.
    Posts
    728

    Re: Code check please

    Code:
    cout<<"The area is: "<<(radius*pi);
    The area of a circle is pi * r^2.
    Digital-X-Treme
    Contact me on MSN Messenger: [email protected]

    [VBCODE]Debug.Print Round(((1097) - ((55 ^ 5 + 311 ^ 3 - 11 ^ 3) _
    / (68 ^ 5))) ^ (1 / 7), 13)[/VBCODE]

  8. #8
    Aerials
    Guest
    oops

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    but in this case, you shouldn't do pi^2 but rather pi*pi (it's faster)
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    That would be pi*r*r right?
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  11. #11
    Addicted Member
    Join Date
    Aug 2001
    Location
    I'm mobile
    Posts
    166
    yepp, correct
    [p r a e t o r i a n]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width