#include <stdio.h> #include <string.h> int main(void) { char userString[50]; strcpy(userString, "Quit"); if (strcmp(userString, "Quit")==0){ printf("Goodbye\n"); } else { printf("Hello\n"); } return 0; }
Print two strings in alphabetical order.
Print the two strings in alphabetical order. Assume the strings are lowercase. End with newline. Sample output:
capes rabbits
#include <stdio.h> #include <string.h> int main(void) { char firstString[50]; char secondString[50]; strcpy(firstString, "rabbits"); strcpy(secondString, "capes"); if (strcmp(firstString, secondString)>0){ printf("%s %s\n", secondString,firstString); } else { printf("%s %s\n",firstString, secondString); } return 0; }