code in c skipping over scanf code example

Example: code in c skipping over scanf

bool isDigit(char num)
{
     if(num>='0' && num<='9')
     {
               return true;
     }    
}

int main (void)
{
char user1 = 0; // declares a character variable for the user inputted function
char ch; // delcares a character variable for the user inputted character

printf ("*****************************************" // Displays the menu system
          "\n* Character Arithmetic      *" // the title
          "\n*****************************************"
          "\n* Program instructions here *" // short instructions
          "\n* Program instructions here *" // short instructions
          "\n*****************************************"
          "\n* Functions: *" // displays the 5 functions
          "\n* a. isDigit *"
          "\n* b. isLetter *"
          "\n* c. toUpper *"
          "\n* d. toLower *"
          "\n* q. Quit *"
          "\n*****************************************");

  printf (" Choose a function: "); // prompts the user to enter a function    
  scanf ("%c", &user1); // saves the user input as 'user1'
  printf ("Enter a character you would like to use the function on: \n"); // asks the user to input a character
  scanf ("%c", &ch); // saves the user inputted character as 'ch'
  
  if ( user1 == 'a' && isDigit(ch) )
  {
       printf ("%c is a digit!\n", ch);
  }
}

Tags:

Misc Example