0

I need the correction to my code

I need an ouptput in this form Enter a character; A The Integer equivalent of A is 65 Enter a character; 1 The Integer equivalent of 1 is 42 Enter a character; 0 The Integer equivalent of 0 is 48 Enter a character; # The Integer equivalent of # is 45 This is the code #include <stdio.h> int main() { char c; scanf("%c", &c); printf("Enter a character: %c\n", c); scanf("%c", &c); printf(" The integer equivalent of %c = %d\n", c, c); char d; scanf("%c", &d); printf("Enter a character: %c\n", d); scanf("%c", &d); printf(" The integer equivalent of %c = %d \n", d, d); char e; scanf("%c", &e); printf("Enter a character: %c\n", e); scanf("%c", &e); printf(" The integer equivalent of %c = %d\n", e, e); char f; scanf("%c", &f); printf("Enter a character: %c\n", f); scanf("%c", &f); printf(" The integer equivalent of %c = %d", f, f); return 0; }

11th Mar 2022, 12:06 PM
David David
3 Answers
0
It should be: for ( int i = 0; i< 4;i++){ char c; printf("Enter a character: "); scanf("%c", &c); printf(" The integer equivalent of %c = %d\n", c, c); } Keep in mind in solo learn the input wont appear next to the prompt
11th Mar 2022, 12:28 PM
Raul Ramirez
Raul Ramirez - avatar
+ 1
If you put your code in sololearn playground, others can test your code and see the syntax highlighting. That way they will be much more ready to help. Go to Code section, click +, select C, put your code there, save it. Come back to this thread, click +, click Insert Code, sort for My Code Bits, select your code.
11th Mar 2022, 12:16 PM
Lisa
Lisa - avatar