0

After entering any value of p,r,n. I am getting SI=0 only. Please help

int main()    
    {
        int p, n;
        float r, s;
        printf ("enter p,n,r \n");
        scanf("%d,%d,%f", &p,&n,&r);
        printf("value of s=%f",s=p*n*r/100);
        return 0;
    }
Vivek
  • 45
  • 5

1 Answers1

2

The commas in the scanf format string will be used to compare the input string.

Therefore, in your program, you have to enter Number,Number,Number such as 20,30,10.

Remove the commas and replace them with spaces, which represent any kinds of whitespaces including spaces and newlines.

scanf("%d %d %f", &p,&n,&r);

Refer to whitespace in the format string (scanf)

Naetmul
  • 14,544
  • 8
  • 57
  • 81