+ 1

This code is not running can anyone please tell me where is the problem?and please give me the solution.

#include<stdio.h> int main() { char colorCode; printf("Enter first word of Red, White or Black: /n"); scanf("%c", %colorCode); switch (colorCode) { case 'r': printf("You select Red."); break; case 'w': printf("You select White."); break; case 'b': printf("You select Black."); break; default: printf("Wrong choose!"); break; } return 0 ; }

19th Sep 2020, 4:45 PM
Suriya Islam
Suriya Islam - avatar
4 Answers
+ 1
scanf("%c", &colorCode);
19th Sep 2020, 4:54 PM
Jayakrishna 🇼🇳
+ 3
Why you set %colorCode in printf?It is colorCode why % ?
19th Sep 2020, 4:49 PM
HBhZ_C
HBhZ_C - avatar
+ 2
See this and in printf statement you write forward slash this will print on Outputs screen line won't be change . You should write backslash \n your mistake is you write % in scanf when you taking input you should write address after comma scanf("%c", &colorCode); #include<stdio.h> int main() { char colorCode; printf("Enter first word of Red, White or Black: \n"); scanf("%c", &colorCode); switch (colorCode) { case 'r': printf("You select Red."); break; case 'w': printf("You select White."); break; case 'b': printf("You select Black."); break; default: printf("Wrong choose!"); break; } return 0 ; }
19th Sep 2020, 5:03 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Thank you everyone
19th Sep 2020, 5:03 PM
Suriya Islam
Suriya Islam - avatar