+ 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 ; }
4 Answers
+ 1
scanf("%c", &colorCode);
+ 3
Why you set %colorCode in printf?It is colorCode why % ?
+ 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 ;
}
+ 2
Thank you everyone