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

Pages: 1-

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 5:31 ID:WvJ+PrV+

>>1
Forget it, it's NP complete.

Name: Anonymous 2007-06-09 5:31 ID:Heaven

This code is awful and incorrect.

Name: Anonymous 2007-06-09 5:35 ID:Heaven

>>3 here
i'd also like to note that >>1 is clearly a troll, no way you declare main as void, have all the variables in a global scope, use only goto and generally all that bullshit
Lastly, nwebs are not aware of octal.

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

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

Name: Anonymous 2007-06-09 12:34 ID:gT4ENm7y

>>5
LOL K
int main() {
   xor eax,eax;
}

Name: Anonymous 2007-06-09 12:36 ID:Heaven

What the butt? "stdafx.h"? Ain't no such thing on muh system!

Shitty win32 shit shit shittiness.

Name: Anonymous 2007-06-09 12:56 ID:Heaven

>>7
It says "std", so it must be standard!

Name: Anonymous 2007-06-09 13:26 ID:CwVxWxWC

>break;                 // Ends this case.

Thanks for informing us

Name: Anonymous 2007-06-09 13:41 ID:gT4ENm7y

>>7
Try installing a compiler.

Name: Anonymous 2007-06-09 18:34 ID:omHvrszL

>>5
Easiest way to troll a GNUfag:

void main() { }

Name: Anonymous 2007-06-09 18:40 ID:jfDCdNhi

goto should be deprecated in every programming language. it just lets morons make moronic code

Name: Anonymous 2007-06-09 18:43 ID:OE3tnE2l

>>12
pointer arithmetic should be deprecated in every programming language. it just lets morons make moronic code

threads should be deprecated in every programming language. it just lets morons make moronic code

regular expressions should be deprecated in every programming language. it just lets morons make moronic code

assignment should be deprecated in every programming language. it just lets morons make moronic code

I could go on but I think I've made my point. You need a better reason than "it could be abused by stupid people" if you're going to argue against a particular language feature.

Name: Anonymous 2007-06-09 18:59 ID:nqB5po8t

>>12
ONE WORD, THE ESCAPING OF NESTED LOOPS. THREAD OVER.

Name: Anonymous 2007-06-09 19:36 ID:xz7XMEz/

>>14
ONE WORD, THINK ABOUT YOUR CODE STRUCTURE MORE CAREFULLY. THREAD OVER.

Name: Anonymous 2007-06-09 20:58 ID:bwAl+fe2

>>15
one word breaking out of nested loops easily. thread over

Name: Anonymous 2007-06-09 22:16 ID:yMskFp1a

>>11,15
>>14 is right

Name: Anonymous 2007-06-10 1:24 ID:Heaven

>>1
THIS IS WHY WE DON'T SUBMIT /prog/ TO REDDIT

Name: Anonymous 2007-06-10 2:57 ID:G1keoG8y

"Lol, what more did you expect? Anyway, I did that because I couldn't figure out how to get other functions to work... If I put the other functions after main(), then I can't use them in main(), cause they haven't been defined yet. And if I put them before main(), they will execute, but then main() won't execute, it will just be skipped.."

From a talk with the author of the code in the OP.

Name: Anonymous 2007-06-10 5:07 ID:Heaven

IF U WERE DROPPED TO /opt TOMORROW, I WOULDNT GO 2 UR DELETION CUZ ID B N UPSTREAM BUGZILLA FLAMIN DA CUNT THAT MADE UR EBUILD!
     __   
   .'  `. 
   |a_a  |
   \<_)__/
   /(   )\
  |\`> < /\
  \_|=='|_/

    WE TRUE NERDS
    WE OPTIMIZE OUR CFLAGS TOGETHER
    WE TALKIN ON IRC WITH www.opera.com TOGETHER
    send this PENGUIN to every thread you care about including this one if you care. C how many times you get this, if you get 256 your A TRUE NERD

Name: Anonymous 2007-06-10 15:05 ID:zdjdInKU

>>20
I lol'd.

Name: Anonymous 2007-06-10 17:09 ID:Heaven

>>21
MORK LURE

Name: Anonymous 2007-06-10 18:15 ID:n+8TRCxI

goto BASIC

Name: ​​​​​​​​​​ 2010-10-26 4:29

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