0

I don't understand why the code is not working - if I run each part alone it works fine, but together it does not.

Here is my code:

#include <stdio.h>

int main()
{
    ///////part 1//////////
    char ch;
    printf("Enter a number between a-z or A-Z: ");
    scanf("%c",&ch);
    printf("The Char's value in the ASCII table is %d\n",ch);
    printf("The following char is %c \n",ch+1);
     /////////// part 2
    char up;
    printf("enter a char between a-z: ");
    scanf("%c",&up);
    printf("upper: %c ",up-32);

    return 0;
}

This is what the compiler shows:

Enter a number between a-z or A-Z: a
The Char's value in the ASCII table is 97
The following char is b 
enter a char between a-z: upper: � 

Why is it not letting me enter the second input (up), and why is it on the same line?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770

0 Answers0