Associate any variable to character

Im trying to create a program that continually reads (loops) a single character from the user and, regardless of the input, displays the ordinal (ASCII) value of the character. If the character is alphabetic, program should also change the case of the character (so if it is an 'a' change to an 'A' and vice-versa) and then display the new ordinal and character values.The program should quit when the user enters the '#' character. The program should display an appropriate message if a non-alphabetic character is entered.

Im stuck on while(mychar == "char');
How do it put = to any char??

Thanks for looking

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
  #include <stdio.h>
#include <ctype.h>


int main()

{
	char mychar;
	
	printf ("Press # to quit or\n");
	printf ("What character do you want to know the value on ASCII: ");
	scanf ("%c%*c", &mychar);
	
	if(mychar == '#')
		printf("Have a nice day\n");
	else
	{
		do
		{
		
		printf("The value is %d\n", mychar);
		printf ("What character do you want to know the value: ");
		scanf ("%c%*c", &mychar);
		
		}while(mychar == "char');
	}

	return(0);
} 
It has to be a c program, sorry and thanks!!
Your code doesn't make sense TBH.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <ctype.h> // toupper(), tolower(), isupper(), islower()

//This function will return the ASCII value of the character
int get_ascii(char c)
{
    return (int)c; //Need to cast the char as an int to get the ASCII value
}

int main()
{
    char ch; //To hold the character

    //Loop till ch equals '#'
    do
    {
        printf("Enter a character: ");
        scanf(" %c", &ch); //Get the character from the user, notice the space before %c
                           //The space tells to ignore the whitespace characters like '\n'
        
        int ascii_value = get_ascii(ch); //Get the ascii value of the character
        printf("\nASCII value of %c: %d\n\n", ch, ascii_value); //Display the ASCII value
        
        if(islower(ascii_value)) //If the character is a lowercase character (a..z)
        {
            char upper_ch = (char)toupper(ascii_value); //Get the uppercase character
            int upper_ascii = get_ascii(upper_ch); //Get the ASCII value of the uppercase character

            //Display the uppercase character and its ASCII value
            printf("Uppercase version of %c is %c.\n", ch, upper_ch);
            printf("ASCII value of %c: %d\n\n", upper_ch, upper_ascii);
        }
        else if(isupper(ascii_value)) //If the character is an uppercase character (A..Z)
        {
            char lower_ch = (char)tolower(ascii_value); //Get the lowercase character
            int lower_ascii = get_ascii(lower_ch); //Get the ASCII value of the lowercase character

            //Display the lowercase character and its ASCII value
            printf("Lowercase version of %c is %c.\n", ch, lower_ch);
            printf("ASCII value of %c: %d\n\n", lower_ch, lower_ascii);
        }
    } while(!(ch == '#'));

    printf("Have a nice day peep! :D\n");

    return 0;
}
Thanks guys
Topic archived. No new replies allowed.