All pastes #1491816 Raw Edit

Mine

public text v1 · immutable
#1491816 ·published 2009-07-11 15:03 UTC
rendered paste body
#/*#include <stdlib.h>##include <netinet/in.h>##include <sys/socket.h>#*/##include <stdio.h>#/*#int a[5];#int i;#*/#char functname[20];#int playcount = 0;#// int play;# #void comparator(); // This is the prototype definition of the function for ANSI C. They#void listnumbers(); // This is the prototype defintion of the function for ANSI C#void infinteloop();#void printnumbers();#void printstring();#void swap(int *, int *);#char getplay();# #main() {#        while(1) {#                        char play;#/*                  play = getplay();#                        while(play == 'y') {#                                int a;#                                printf("DID WE GET HERE? INFINTELOOP()???");#                                scanf("%d" , &a); // INFINTE LOOP EXAMPLE#                        if(a==10) {#                                printf("end of infinte loop");# #        }# #                        }#*/# #                int i;#                printf("\n***********************");#                printf("\n*****INPUT CHOICE******");#                printf("\n***********************");#                printf("\n**  1. listnumbers() **");#                printf("\n**  2. comparator()  **");#                printf("\n**  3. infinteloop() **");#                printf("\n**  4. printnumbers()**");#                printf("\n**  5. printstring() **");#                printf("\n***********************");#                printf("\n***********************");#                printf("\nInput 1-5: ");#                scanf("%d", &i);#                switch (i) {#                        case 1:#                        listnumbers();#                        break;#                        case 2:#                        comparator();#                        break;#                        case 3:#                        strcpy(functname, "infinteloop");#                        play = getplay();#                        while(play == 'y') {#                                infinteloop();#                        }#                        break;#                        case 4:#                        printnumbers();#                        break;#                        case 5:#                        printstring();#                        break;#                        default:#                        printf("Invalid input");#                        break;#                }#                // swap(1,2);#/*      int r = rand() % 100; // RANDON NUMBER EXAMPLE - If you look at the last two digits of all of these numbers they would form our random set! To select just these numbers we can use an arithmetic calculation of the following form: That is, to get the number into the right range you simply take the remainder on dividing by 100, ie a value in the range 0 to 99.#        printf("\nOk, time to guess %d... ", r);#        scanf("%d" , &a);#        while(a != r) {#                printf("\nTry again...");#                if (a < r) {#                        printf("Too low.\n");#                }#                else {#                        printf("Too high.\n");#                }#                scanf("%d" , &a);#        }#        if(a == r) {#                printf("\nCorrect! Look at the big brain on Bret!\n");#        } */#}#return 0;#}# #void swap(int *a, int *b) {#                int temp;#                temp = *a; // temp is equal to the value of point a (whatever the first incoming param is)#                *a = *b; // *a is equal to the value of pointer b (whatever the second incoming param is)#                *b = temp; // now *b is equal to the value of temp (which was a)#        //      printf("%d" , a , b);#}#void printstring() {#        char a[40];#//      strcpy(a, "hello");#       #        //printf("OK lets have it, 40 characters max: ");#        //scanf("%s", a);#        printf("Thanks, here it is...\n\n");#        printf("%s", a);#        printf("\n\n");#       #}#void infinteloop() { // under construction to fix overall control styles#        int a;#        printf("\nWe made it to infinteloop()\n");#        scanf("%d" , &a); // INFINTE LOOP EXAMPLE#        while(a==10) {#                printf("\nEnd of infinte loop...\n");#                break;#        }#        printf("\n We made it to return in infinteloop()..\n");#}# #char getplay() {#        int play;#        printf("Play %s y/n ?" , functname);#        play = -1;#        while (play == -1) {#      play=getchar();#        }#        return play;#}# #void comparator(int play, int a, int b) {#        printf("\nHello this is comparator()");#        printf("\nDo you want to play? Y=1 N=0: ");#        scanf("%d" , &play);#        while(play) {#                printf("\nEnter first number: ");#                scanf("%d" , &a); // %d represents the data type for numbers#                printf("\nEnter second number: ");#                scanf("%d" , &b);#       #                if(a>b) {#                        printf("\nFirst number greater than second");#                        printf("\nDifference is: %d\n\n", a-b);#                }#                else if(a<b) {#                        printf("\nSecond number greater than first");#                        printf("\nDifference is: %d\n\n", b-a);#                }#                else {#                        printf("\n\nHey whats going on here buddy? Its equal. Ill cut you.\n\n");#                }#                return;#        }#}#void listnumbers(int play, int i, int a[5]) {#        printf("\nHello this is listnumbers()");#        printf("\nDo you want to play? Y=1 N=0: ");#        scanf("%d" , &play);#        while(play) {#                for(i = 0; i < 5; i  ) { // FOR LOOP EXAMPLE#                        printf("Input %d:",i);#                        scanf("%d",&a[i]);#                }#                if(i == 5) {#                        printf("Thanks for the input, dick.\n");#                }#                printf("Numbers were:");#                for(i = 0; i < 5; i  ){#                        printf("%d,",a[i]);#                }#                printf("\n");#                return;#        }#}#void printnumbers(int play, int a) {#        printf("\nHello this is printnumbers()");#        printf("\nDo you want to play? Y=1 N=0: ");#        scanf("%d" , &play);#        while(play) {#                printf("\nInput a number 1-3 and press return: ");#                scanf("%d" , &a);#                switch(a) {#                        case 1:#                                printf("one\n");#                                break;#                        case 2:#                                printf("two\n");#                                break;#                        case 3:#                                printf("three\n");#                                break;#                        default:#                                printf("\n\n###Unrecognized number###\n\n");#                }#                break;#        }#}