Created
December 29, 2016 22:44
-
-
Save s3f/9ac40d2c5ca5a078ac160b612472cc0b to your computer and use it in GitHub Desktop.
Chapter 6 - Adding Words to Your Program created by s3f - https://repl.it/E9m0/1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* WARMUP CODE | |
#include <stdio.h> | |
int main () | |
{ | |
char char1 = 'X'; | |
char char2 = 'M'; | |
char char3 = 'L'; | |
printf("The reverse of %c%c%c is %c%c%c\n", | |
char1, char2, char3, | |
char3, char2, char1); | |
return 0; | |
} | |
*/ | |
// The following program pairs 3 kids with their favorite superheroes | |
#include <stdio.h> | |
#include <string.h> | |
main() | |
{ | |
char kid1 [12]; | |
char kid2 [] = "Maddie"; | |
char kid3 [7] = "Andrew"; | |
char hero1 = "Batman"; | |
char hero2 [34] = "Spiderman"; | |
char hero3 [25]; | |
kid1[0] = 'K'; | |
kid1[1] = 'a'; | |
kid1[2] = 't'; | |
kid1[3] = 'i'; | |
kid1[4] = 'e'; | |
kid1[5] = '\0'; | |
strcpy(hero3, "The Incredible Hulk"); | |
printf("%s\'s favorite hero is %s.\n, kid1, hero1"); | |
printf("%s\'s favorite hero is %s.\n, kid2, hero2"); | |
printf("%s\'s favorite hero is %s.\n, kid3, hero3"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment