Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004
    Posts
    5,837
    Tokens
    2,203

    Latest Awards:

    Default [Help pls] Is this a good layout (c++)

    I'm currently learning basic level c++ in college (Just started).

    I'm wondering, is this a good layout?

    Code:
    #include<iostream>
    #include<conio.h>
    
    using namespace std;
    
    void main(void)
    
    {
    float radius, height, volume, surfacearea, sumone, sumtwo;
    	cout<<"Please enter Radius ";
    	cin>>radius;
    	cout<<"Please enter Height ";
    	cin>>height;
    							volume=3.142*radius*radius*height;
    							sumone=2*3.142*radius*radius;
    							sumtwo=2*3.142*radius*height;
    							surfacearea=sumone+sumtwo;
    	cout<<"Volume "<<volume<<endl;
    	cout<<"Surface Area "<<surfacearea<<endl;
    getch();
    }
    Or would it be better to just leave everything as is?

    moderator alert Edited by Catzsy (Forum Super Moderator): Thread moved from 'Technology Discussion ' to here as probably more suitable
    Last edited by Catzsy; 16-09-2011 at 09:09 AM.

  2. #2
    Join Date
    Jul 2004
    Location
    California
    Posts
    8,725
    Tokens
    3,789
    Habbo
    HotelUser

    Latest Awards:

    Default

    Do you mean layout in terms of ease to read, or layout in terms of maximizing the efficiency of your program? If the latter it's fine from my perspective, if the foremost your layout looks fine, abit messy in spots:

    Code:
    #include<iostream>
    #include<conio.h>
    
    using namespace std;
    
    void main(void)
    {
            //declare variables
            float radius, height, volume, surfacearea, sumone, sumtwo;
    
            //collect user input
    	cout << "Please enter Radius ";
    	cin >> radius;
    	cout << "Please enter Height ";
    	cin >> height;
    
            //preform mathematical calculations
    	volume = 3.142 * radius * radius * height;
    	sumone =2 * 3.142 * radius * radius;
    	sumtwo =2 * 3.142 * radius * height;
    	surfacearea = sumone + sumtwo;
    
            //display results and keep application running
    	cout << "Volume " << volume << endl;
    	cout << "Surface Area " << surfacearea << endl;
            getch();
    }
    Last edited by HotelUser; 16-09-2011 at 02:46 AM.
    I'm not crazy, ask my toaster.

  3. #3
    Join Date
    Sep 2011
    Location
    Australia
    Posts
    41
    Tokens
    0
    Habbo
    Unfamiliar

    Latest Awards:

    Default

    Comments will make every ones world a better place and I'm sure your teacher would appreciate it too. Just a few words describing what you are doing in the following section usually does the trick.

    Then again, if you're in college hopefully they teach you how to format / present your code.


    Always looking for a chat ~ PM ME ~

Posting Permissions

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