0

What I am missing here

#include <stdio.h> #include<string.h> struct emp { int emp_id; char name; double salary; } E1,E2; int main() { printf("Enter the id , name and salary of employee 1 : \n"); scanf("%d%c%lf",&E1.emp_id,&E1.name,&E1.salary); printf("Enter the id ,name and salary of employee 2 : \n"); scanf("%d%c%lf",&E2.emp_id,&E2.name,&E2.salary); if (E1.salary>5000) { printf("Employee 1 having salary %lf greater than 5000 \n ",E1.salary); } else if (E2.salary>5000) { printf("Employee 2 having salary %lf greater than 5000 \n ",E2.salary); } else { printf("Nobody is getting salary above 5000."); } return 0; }

7th Jan 2022, 7:02 AM
Mr. A
Mr. A - avatar
2 Answers
+ 4
Put a space in between the conversion specifiers when you use scanf() to read inputs. "%d %c %lf" And in input dialog (when running in Code Playground), provide inputs in single line 101 A 6000 202 Z 7000 NOTE: This way 'name' can only contain a character, not a full name.
7th Jan 2022, 7:15 AM
Ipang
+ 1
So instead of that I should string ?
7th Jan 2022, 5:37 PM
Mr. A
Mr. A - avatar