Solved if statment

June 21, 2011 at 02:22:06
Specs: Windows 7
help me in if (salary <400 || salary>1500)
printf ("the salary must be between 400 and 1500");
else (salary >400 || salary <1500)
printf ("Yes");

See More: if statment

Report •

#1
June 21, 2011 at 08:34:48
✔ Best Answer
you could try something like

   char buf[10];
   int salary;

   do {
      printf("Enter salary (400 - 1500): ");
      fgets(buf, sizeof buf, stdin);
   } while((sscanf(buf, "%d", &salary)) != 1 || (salary < 400 || salary > 1500));

   printf("\nsalary %d\n", salary);

#include <string.h> for sscanf

HTH


Report •

#2
June 21, 2011 at 23:18:16
You've missed out an "if" after the "else".

Report •

#3
June 22, 2011 at 00:26:23
Thanks I will try to do it

Report •
Related Solutions


Ask Question