Thread: Basic Questions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2017
    Posts
    4

    Basic Questions

    Hi, I'm an absolute beginner to coding in C, and I'm attempting to practice by writing a program where a user responds to Yes/No questions in a series, like if it were a game. The problem that I'm having is that after the first question is answered, and the second pops up, the program doesn't give me (the user) a chance to respond to it; the program abruptly ends. Obviously, there must be something simple that I'm missing here to go from one question to another without it terminating. I'd appreciate any advice.

    Here's what I've made so far:

    Code:
    #include <stdio.h>
    
    char answer, answertwo;
    
    int main()
    {
    
    printf ("Are you laughing? (Y/N)\n" );
    scanf ("%c", &answer);
    
    if (answer == 'y' || answer == 'Y')
    printf("\nGood\n");
    else if (answer == 'n' || answer == 'N')
    printf("\nBye\n");
    
    
    printf("Do you want to read? (Y/N)\n ");
    scanf ("%c, &answertwo");
    if (answertwo == 'y' || answertwo == 'Y')
    printf("\nGood\n");
    else if (answertwo == 'n' || answertwo == 'N')
    printf("\nBye\n");
    
    return 0;
    
    }
    Last edited by NightTower; 02-02-2017 at 04:02 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A Few Basic Questions
    By Euclid365BCE in forum C Programming
    Replies: 2
    Last Post: 10-21-2015, 07:46 AM
  2. Basic Questions
    By Panda_ in forum C Programming
    Replies: 15
    Last Post: 09-23-2009, 04:24 PM
  3. Some Basic questions
    By BlaX in forum C Programming
    Replies: 7
    Last Post: 06-30-2009, 09:51 AM
  4. hello. basic questions
    By johnnyboy in forum C++ Programming
    Replies: 14
    Last Post: 02-01-2008, 10:58 AM
  5. Basic questions about C
    By FlatLost in forum C Programming
    Replies: 6
    Last Post: 11-01-2005, 01:08 PM

Tags for this Thread