| 
 Facking around - Malcolmforde -  06-06-2013
 
 Calculator with subtraction/addition/voting! :3
 
 Edited to use booleans for loops:
 
 Code: #include <stdio.h>#include <stdbool.h>
 
 main()
 {
 bool loop = true;
 int op;
 
 printf("Type '0' for a list of operations\ncurrently available.\n");
 while (loop == 1) {
 scanf("%d", &op);
 if (op == 0) {
 printf("Type 1 for Addition,\n2 for Subtraction,\n3 for a voting system.\nPlease note that only integers are supported!\n");
 };
 if (op == 1) {
 --loop;
 add();
 };
 if (op == 2) {
 --loop;
 sub();
 };
 if (op == 3) {
 --loop;
 vote();
 };
 };
 };
 
 add()
 {
 int inputA;
 int inputB;
 
 printf("Addition selected\nPlease give input for input A\n");
 scanf("%d", &inputA);
 printf("Thank you.\nNow please provide input B.\n");
 scanf("%d", &inputB);
 printf("Now calculating\n");
 while (inputA != 0) {
 ++inputB;
 --inputA;
 };
 printf("Calculation complete.\nResult: %d\n", inputB);
 main();
 };
 
 sub()
 {
 int inputA;
 int inputB;
 
 printf("Subtraction selected\nPlease give input for input A\n");
 scanf("%d", &inputA);
 printf("Thank you.\nNow please provide input B.\n");
 scanf("%d", &inputB);
 printf("Now calculating\n");
 while (inputB != 0) {
 --inputB;
 --inputA;
 };
 printf("Calculation complete.\nResult: %d\n", inputA);
 main();
 };
 
 vote()
 {
 int variA;
 int variB;
 int buffer;
 int loop = 1;
 
 printf("Usage: Have everyone come up to the\ncomputer and type either 1 or 2 to\nrepresent their choice. When voting\nis done, type 3.\n");
 while(loop == 1) {
 scanf("%d", &buffer);
 if (buffer == 1) {
 ++variA;
 buffer = 0;
 };
 if (buffer == 2) {
 ++variB;
 buffer = 0;
 };
 if (buffer == 3) {
 --loop;
 buffer = 0;
 };
 if (buffer > 3) {
 printf("Invalid operation!\n");
 buffer = 0;
 };
 };
 if (variA > variB) {
 printf("Option 1 wins!\n");
 };
 if (variA < variB) {
 printf("Option 2 wins!\n");
 };
 if (variA == variB) {
 printf("Tie!\n");
 };
 main();
 };
Not fully edited (I need to set the --loop to loop = false instead) but it works.
 
 Old one:
 
 
 Code: #include <stdio.h>
 main()
 {
 int loop = 1;
 int op;
 
 printf("Type '0' for a list of operations\ncurrently available.\n");
 while (loop == 1) {
 scanf("%d", &op);
 if (op == 0) {
 printf("Type 1 for Addition,\n2 for Subtraction,\n3 for a voting system.\nPlease note that only integers are supported!\n");
 };
 if (op == 1) {
 --loop;
 add();
 };
 if (op == 2) {
 --loop;
 sub();
 };
 if (op == 3) {
 --loop;
 vote();
 };
 };
 };
 
 add()
 {
 int inputA;
 int inputB;
 
 printf("Addition selected\nPlease give input for input A\n");
 scanf("%d", &inputA);
 printf("Thank you.\nNow please provide input B.\n");
 scanf("%d", &inputB);
 printf("Now calculating\n");
 while (inputA != 0) {
 ++inputB;
 --inputA;
 };
 printf("Calculation complete.\nResult: %d\n", inputB);
 main();
 };
 
 sub()
 {
 int inputA;
 int inputB;
 
 printf("Subtraction selected\nPlease give input for input A\n");
 scanf("%d", &inputA);
 printf("Thank you.\nNow please provide input B.\n");
 scanf("%d", &inputB);
 printf("Now calculating\n");
 while (inputB != 0) {
 --inputB;
 --inputA;
 };
 printf("Calculation complete.\nResult: %d\n", inputA);
 main();
 };
 
 vote()
 {
 int variA;
 int variB;
 int buffer;
 int loop = 1;
 
 printf("Usage: Have everyone come up to the\ncomputer and type either 1 or 2 to\nrepresent their choice. When voting\nis done, type 3.\n");
 while(loop == 1) {
 scanf("%d", &buffer);
 if (buffer == 1) {
 ++variA;
 buffer = 0;
 };
 if (buffer == 2) {
 ++variB;
 buffer = 0;
 };
 if (buffer == 3) {
 --loop;
 buffer = 0;
 };
 if (buffer > 3) {
 printf("Invalid operation!\n");
 buffer = 0;
 };
 };
 if (variA > variB) {
 printf("Option 1 wins!\n");
 };
 if (variA < variB) {
 printf("Option 2 wins!\n");
 };
 if (variA == variB) {
 printf("Tie!\n");
 };
 main();
 };
 
 RE: Facking around - Chibill -  06-06-2013
 
 Boo make it work from minecraft!
 
 
 RE: Facking around - Malcolmforde -  06-07-2013
 
 
  (06-06-2013, 04:01 AM)Chibill Wrote:  Boo make it work from minecraft! No.
 
 
 RE: Facking around - Chibill -  06-07-2013
 
 Why I can.
 
 
 RE: Facking around - David -  06-07-2013
 
 Chibill, your sig is way to big...
 
 
 RE: Facking around - mad1231999 -  06-07-2013
 
 Why use ints?
 
 
 RE: Facking around - Xeomorpher -  06-07-2013
 
 Yea, actually, chi, can you make the signature smaller? for example, the size of what is depicted on it?
 
 
 RE: Facking around - Nickster258 -  06-07-2013
 
 
  (06-07-2013, 01:57 PM)David Wrote:  Chibill, your sig is way to big... Nah, his is just fine.
 
 And yes, I'll decrease the resolution and reupload my sig for you guys, when I get time to.
 
 
 RE: Facking around - Malcolmforde -  06-08-2013
 
 
  (06-07-2013, 03:08 PM)mad1231999 Wrote:  Why use ints? Fixed
 
 
 RE: Facking around - Chibill -  06-08-2013
 
 I can try that's how t uploaded to the image website as.
 
 
 RE: Facking around - mad1231999 -  06-08-2013
 
 
  (06-08-2013, 04:44 AM)Malcolmforde Wrote:   (06-07-2013, 03:08 PM)mad1231999 Wrote:  Why use ints? Fixed
 Nope, still wrong. No reason to use 3 extra bytes! XD
 
 
 RE: Facking around - Malcolmforde -  06-08-2013
 
 
  (06-08-2013, 08:12 AM)mad1231999 Wrote:   (06-08-2013, 04:44 AM)Malcolmforde Wrote:   (06-07-2013, 03:08 PM)mad1231999 Wrote:  Why use ints? Fixed
 Nope, still wrong. No reason to use 3 extra bytes! XD
 xD
 
 
 
 |