Difference: CppCodingStyleStandards (1 vs. 2)

Revision 22016-09-06 - JimSkon

Line: 1 to 1
 
META TOPICPARENT name="WebHome"

C++ Coding Style Standard

Line: 6 to 6
 

Features

  • Indentation - Code should be indented to match how deeply it is embedded within code blocks (between { and } )
  • Comments - You should carefully, and precisely, place comments through the program to explain that may not be completely clear with an explaination. You should also use comments to what the program does, who wrote it, what date it was created, and when appropriate a dated change history.
Changed:
<
<
>
>
  • Indentifier Names - Should be meaningful with respect to the purpose they serve in the code.
  %CODE{"c++"}% //File Name: health.cpp

Revision 12016-09-05 - JimSkon

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="WebHome"

C++ Coding Style Standard

Coding style is important as it make easier to read, easier to correct, and easier to change. It is an investment in the future!

Features

  • Indentation - Code should be indented to match how deeply it is embedded within code blocks (between { and } )
  • Comments - You should carefully, and precisely, place comments through the program to explain that may not be completely clear with an explaination. You should also use comments to what the program does, who wrote it, what date it was created, and when appropriate a dated change history.

<-- SyntaxHighlightingPlugin -->
//File Name: health.cpp 
//Author: Your Name Goes Here.
//Email Address: you@yourmachine.bla.bla
//Assignment Number: 2
//Description: Program to determine if the user is ill.
//Last Changed: September 23, 2016

#include <iostream>
using namespace std;
int main( )
{
    const double NORMAL = 98.6;//degrees Fahrenheit
    double temperature;

    cout << "Enter your temperature: ";
    cin >> temperature;
    if (temperature > NORMAL)
    {
        cout << "You have a fever.\n";
        cout << "Drink lots of liquids and get to bed.\n";
    }
    else 
    {
        cout << "You don't have a fever.\n";
        cout << "Go study.\n";
    }
    return 0;  
}
<-- end SyntaxHighlightingPlugin -->

-- Jim Skon - 2016-09-05

Comments

<--/commentPlugin-->
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback