/* write a program that reads a character, if the character is 'a' or 'A' the program prints an ASCII value of 'a' and 'A', if the character is 'b' or 'B', the program prints the character and its ASCII value, if the character is 'c' or 'C', the program prints the sum of ASCII values of 'c' and 'C' if the character is not one of the above, the program prints an error message USE SWITCH statement - can be used with characters or integers only. */ #include int main(){ char ch; int ascii_value1, ascii_value2, sum; printf("enter character\n"); scanf("%c",&ch); switch(ch){ case 'a': //if(ch=='a' || ch=='A') case 'A': ascii_value1=(int)('a'); ascii_value2=(int)('A'); printf("the ASCII of %c is %d\n",'a', ascii_value1); printf("the ASCII of %c is %d\n",'A', ascii_value2); break; case 'b': //else if(ch=='b' || ch=='B') case 'B': printf("the ASCII of %c is %d\n", ch, (int)(ch)); break; case 'c': case 'C': sum=(int)('c')+(int)('C'); printf("sum is %d\n",sum); break; default: printf("invalid input\n"); break; } return 0; }