1, numerical type is not easy to master.
Decimals are likely to appear when calculating wages, but the landlord completely adopts int type when declaring variables, regardless of whether it is logically correct or not. A variable of type int directly conflicts with the following code.
There are two problems:
1. 1:
In scanf (), the landlord wrote %ld in brackets, the input type of %ld is long int, and the landlord declared that,
int .
1.2:
I commission =(iSales * 1.5);
ISales is an integer, 1.5 is a floating point, the result of iSales* 1.5 is implicitly converted to a floating point, and iCommission is.
An integer int error will occur when assigning values.
Need to add knowledge points: definition and conversion of parameter types. Please refer to any C language textbook.
2. The 2.scanf () function is not well mastered.
This is also the main concern of the landlord. In scanf () \n, spaces and tabs are blank characters. White space characters cause the scanf () function to ignore one or more white space characters in the input during a read operation. The input of scanf can only be terminated when a non-blank character is input. In addition, the parameter types mentioned above also need special attention.
Need to add knowledge points: how to use the scanf () function. Please refer to the relevant documents.
/link? URL = ed 3 zutax n 3 lk byp 49 NP 1 qfyvfaxckq 1j _ fvptcqsrctkoonskicking rec 7 ffvuaq 7 JM H5 udi 3 bjzbbnbv 8 ldvq
Say a few more words: put option; The function is used to write a string to the standard output device (screen) and wrap it. Its calling method is: puts (s); Where s is a string character (string array name or string pointer). Although the landlord uses it correctly, it is better to consult a more standard method.
/link? URL = mvsb 8 twqqpmlwzkve 4 ipvgamu _ 2P-RF 63hg 3 euc 3c b 7 xrp 53k 35 bs 9 IQ _ 8 ia 3y 2 lqraz 0 zctenpgzg 8 RLS yk
Post my modified code below:
# Contains? & ltstdio.h & gt
int? Master ()
{
Double? iSalary,iBasic,iCommission,iSales
Printf ("Please? Enter? That? Foundation? Payment: ");
scanf("%lf ",& ampiBasic);
Printf ("Please? Enter? That? Sales: ");
Scanf("%lf ",& Isales);
I commission =(iSales * 1.5);
Printf ("commission salary: %lf\n", i commission);
iSalary =(iBasic+I commission);
Printf ("monthly salary:");
printf("%lf ",iSalary);
Return? 0;
} Please pay attention to the change of variable type and the change after% in input and output.
Tip: The details in the programming process are really important. In addition, if you encounter problems in the future, try to break them down into small problems, then find relevant solutions and learn to make good use of search engines. For example, if the landlord encounters a problem when inputting, he should think about whether there is a problem with scanf, and then search for its correct usage. This is the real solution to the problem.