0
Why I am getting both outputs?
#include<stdio.h> int main() { char a; printf("Enter the subject"); scanf("%s",&a); if(a= 'maths' ) { printf("You won ₹10"); } else if(a= 'science'); { printf("You won ₹20"); } else (a= 'science and maths'); { printf("You won ₹45"); } return 0; }
1 Réponse
0
#include<stdio.h>
#include<string.h>
int main()
{
char a[50];
printf("Enter the subject");
scanf("%s",a);
if(strcmp("maths",a)==0 )
{
printf("You won ₹10");
}
else if(strcmp("science",a)==0 )
{
printf("You won ₹20");
}
else
{
printf("You won ₹45");
}
return 0;
}