Read in a last name, and check if the user has a last name that starts with a letter between P and Q - C Language Basics

C examples for Language Basics:scanf

Description

Read in a last name, and check if the user has a last name that starts with a letter between P and Q

Demo Code

#include <stdio.h>
int main()/* w  w  w  .  j  a  v  a2s  .c o m*/
{
    char name[25];

    printf("What is your last name? ");
    printf("(Please capitalize the first letter!)\n");
    scanf(" %s", name);

    if ((name[0] >= 'P') && (name[0] <= 'S'))
    {
        printf("between p and q");
    }
    else
    {
        printf("not.\n");
    }

    return 0;
}

Result


Related Tutorials