Page 1 of 1

Joke programs from my cs 135 class

Posted: Fri Sep 22, 2017 4:29 pm UTC
by gd1
#include <stdio.h>

int main (void)
{
char declarationofindependence[] = "When in the Course of human events...";
printf("%s\n", declarationofindependence);

return 0;
}

because we were talking about declarations in class (though I think that might not be?)

=========================================

//Prints dance to the screen using a switch and break statements then prints break
#include <stdio.h>
int main(void)
{
int breakdance;

printf("Enter a number of times from 1 to 5 to print dance: ");
scanf("%d", &breakdance);
switch (breakdance)
{
case 1: printf("Dance\n"); break;
case 2: printf("Dance\nDance\n"); break;
case 3: printf("Dance\nDance\nDance\n"); break;
case 4: printf("Dance\nDance\nDance\nDance\n"); break;
case 5: printf("Dance\nDance\nDance\nDance\nDance\n"); break;
default: printf("\n"); break;
}
printf("Break\n");
return 0;
}

because we were talking about breaks in class

Feel free to also post your joke programs or ones you like.

Re: Joke programs from my cs 135 class

Posted: Fri Sep 22, 2017 5:19 pm UTC
by Mike Rosoft
Text adventure game (for two players):

Code: Select all

10 INPUT a$
20 PRINT a$
30 GO TO 10