C examples for Language Basics:scanf
Read in a last name, and check if the user has a last name that starts with a letter between P and Q
#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; }