Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.c
- // Adam
- //
- // Created by Shahin on 2015-03-09.
- // Copyright (c) 2015 98% Chimp. All rights reserved.
- //
- #include <stdio.h>
- #include <stdbool.h>
- #include <ctype.h>
- #include <string.h>
- int main(int argc, const char * argv[]) {
- // insert code here...
- bool isDone = false;
- while (isDone == false) {
- printf("Please type in your question for Adam (type exit to discontinue): ");
- char input[]="";
- rewind(stdin);
- scanf("%[^\n]", input);
- long length = strlen(input);
- long len = length - 1;
- char *s1 = &input[len];
- char *s2 = "?";
- char *exit = "exit";
- bool uppercase = true;
- if (strcmp(input, exit) == 0) {
- isDone = true;
- printf("Yo yo!\n");
- }
- else if (length > 0) {
- for (int i = 0; i < length; i++) {
- if (!((input[i] >= 65 && input[i] <= 90) || input[i] == 32)) {
- uppercase = false;
- break;
- }
- }
- if (uppercase) {
- printf("Woah, chill out!\n");
- }
- else if (strcmp(s1, s2) == 0) {
- printf("Sure!\n");
- }
- else {
- printf("Whatever!\n");
- }
- }
- else {
- printf("Fine. Be that way!\n");
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement