0

Need a little help with strings in c

Here is my code #include<stdio.h> #include<string.h> int main() { int x,y,z; char a[2], b[]="has the minimal seating capacity"; printf("Enter x\n"); scanf("%d", &x); printf("Enter y\n"); scanf("%d", &y); printf("Enter z\n"); scanf("%d", &z); printf("Enter the lab allocated for ACE training\n"); scanf("%s", a); if(!strcmp(a,"L1")) { (y<z) ? printf("L2 %s", b) : printf("L3 %s", b); } else if(!strcmp(a,"L2")) { (x<z) ? printf("L1 %s", b) : printf("L3 %s", b); } else { (x<y) ? printf("L1 %s", b) : printf("L2 %s", b); } return 0; } So if this is my input Enter x 30 Enter y 40 Enter z 20 Enter the lab allocated for ACE training L3 Output should be : L1 has the minimal seating capacity But output is only : L1 Why?? Why isn't "has the minimal seating capacity" printed..??

21st Jan 2018, 6:27 AM
Ayush walia
Ayush walia - avatar
2 Answers
- 1
SoloLearn's code playground lets you to take something from user one time. You can't take multiple inputs.
21st Jan 2018, 8:11 AM
Mustafa K.
Mustafa K. - avatar