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 Answer
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;
}