Answers for "y/n as only option in C"

C
0

y/n as only option in C

#include <stdio.h>

int main() {

    printf("Are you sure to continue? y/n ");

    char c;

    scanf(" %c", &c);

    switch (c) {

        case 'y':

            printf("program continues\n");
        break;

        case 'n':
            printf("program stops\n");
        break;

        default:
            printf("wrong option\n");
    }
}
Posted by: Guest on September-10-2021

Code answers related to "C"

Browse Popular Code Answers by Language