c - How to get the correct output in the program? -


#include <stdio.h> long double main () { long double sal,tax; printf ("enter salary"); scanf ("%ld",&sal); if (sal>=1000000)     tax=sal*0.3;     else if (sal<1000000&&sal>=500000)     tax=sal*0.2;    else if (sal<500000&&sal>=200000)     tax=sal*0.1; else     tax=0;  printf ("the tax %ld",tax); return 0; } 

the expected output of program display tax, whenever program executed gives value of tax 0 value of salary. have tried changing data types int, void, long, double, float, long double , still can't desired output.

your program behaviour undefined:

"%lf" correct format specifier long double.

also, return type of main should int. else implementation defined. until know you're doing, use int.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -