Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

LOL I KNOW C++

Name: Anonymous 2007-06-09 5:27 ID:DMJjPWxt

// Files to include:
#include <stdafx.h>
#include <iostream>

// Allow, for example, cout >> "hello"; rather than std::cout >> "hello"; in code:
using namespace std;

// Define all the variables the program uses:
int selection, a, b, c, d, e, sum, difference, product, quotient, foil1, foil2, ext, around, arn, arnd;

void main()                     // Defines function main()                        
{
  selection = 012021;           // Sets variable "selection" to 012021.

choose:                         // "Choose:" labels the section where the program continues
                                // differently based on the inputted value for var "selection".
     while(selection != 0)      // Everything within the { and } of this section is skipped if
                                // selection = 0, aka the "While selection doesn't = 0" section.
 {                              // It does this because 0 is the selection number for exiting.
     switch(selection)
  {
       case 1:                  // What the program does if selection = 1. 
         goto add;              // Goes to the label called "add".
         addcase:               // This is used to come back to this section after adding.
         goto menu;             // After displaying the result, another selection can be made.
         break;                 // Ends this case.

       case 2:                  // See case 1.
         goto subtract;
         subtractcase:
         goto menu;
         break;

       case 3:                  // See case 1.
         goto multiply;
         multiplycase:
         goto menu;
         break;

       case 4:                  // See case 1.
         goto divide;
         dividecase:
         goto menu;
         break;

       case 5:                  // The incomplete foil function. It doesn't go to any label.
         cout << "\nSyntax: a^b+c*d+e\n\n";
         cout << "This function is incomplete.\n\n";
         goto menu;
         break;

       case 012021:             // When the program begins, the info section is displayed.
         goto info;
         break;

       default:
         cout << "\nSelection number " << selection << " is not a valid function.\n\n";  
         goto menu;
         break;
  }

info:                           // Labels the Info section, which displays the menu.
       cout << "--------------\n Calculatizor\n--------------\n\n"; 
       cout << "Select a function:\n\n1. Add \n2. Subtract\n3. Multiply\n4. Divide\n5. Foil\n0. Exit\n\n"; 
       goto menu;
menu:                           // Labels the menu section. Prompts user to select a fucntion.
       cout << "Selection: "; 
       cin >> selection;
       goto choose;

//Functions:
add:                           // Labels the add section.
       cout << "\nInput a number: "; cin >> a;  // Prompts user for value of first number.      
       cout << "\nInput another number: "; cin >> b;  // Prompts user for value of first number.    
       sum = a + b;            // The calculation is made.
       cout << "\n" << a << " + " << b << " = " << sum << "\n\n";  // Calculation is displayed.
       goto addcase;           // Then goes back to case 1 (what happens when selection = 1).

subtract:                      // Refer to the add section.
       cout << "\nInput a number: "; cin >> a;                             
       cout << "\nInput another number: "; cin >> b;
       difference = a - b;
       cout << "\n" << a << " - " << b << " = " << difference << "\n\n"; 
       goto subtractcase;

multiply:                      // Refer to the add section.
       cout << "\nInput a number: "; cin >> a;                             
       cout << "\nInput another number: "; cin >> b;                                 
       product = a * b;
       cout << "\n" << a << " x " << b << " = " << product << "\n\n";   
       goto multiplycase;
divide:                           // Refer to the add section.
       cout << "\nInput a number: "; cin >> a;                             
       cout << "\nInput another number: "; cin >> b;                               
       quotient = a / b;
       cout << "\n" << a << " / " << b << " = " << quotient << "\n\n";  
       goto dividecase;
  }                            // End of "while selection does not equal 0" section.
}                              // end of function main()

Name: Anonymous 2007-06-09 12:17 ID:NrgdtE9t

INT main you fucking faggot, INT main should return INT.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List