0
#include<stdio.h>
int main(void)
{
    float basic, da, hra, total;
    printf("Enter basic salary: ");
    scanf("%f ", &basic);
    da = 0.4 * basic;
    hra = 0.2 * basic;
    total = basic + da + hra;
    printf("Ramesh total salary is = %f", total);
    return 0;
}

The compiler shows no error and when I enter the salary there is no outputenter image description here

john
  • 85,011
  • 4
  • 57
  • 81
  • please do only tag the language you are using. This looks like C – 463035818_is_not_an_ai Aug 02 '22 at 08:32
  • 1
    Take some time to think about that trailing space in the `scanf` format string. What do you think it does? – Some programmer dude Aug 02 '22 at 08:36
  • The trailing whitespace in the `scanf()` format string tells it to filter *any amount* of whitespace, but the function won't know how much that is until you actually enter a non-whitespace character. Every character in the format string has a purpose. – Weather Vane Aug 02 '22 at 08:39
  • @Someprogrammerdude I removed that trailing space in scanf an program worked. But I still have no idea why trailing space was causing that problem. Sir can you please elaborate why trailing space caused the problem – PradeepYDK Aug 02 '22 at 08:41
  • 3
    Please see previous comment, and *read the duplicate*. – Weather Vane Aug 02 '22 at 08:41

0 Answers0