-C编程错误- [英] -C programming error -
本文介绍了-C编程错误-的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#include <stdio.h>
void main (void)
{
float no_week;
int no_hour;
int hour;
int no_item;
int salary_perweek;
float paycode_1;
float paycode_21;
float paycode_22;
float paycode_3;
float paycode_4;
float salarypaycode_1;
salary_perweek = 500;
hour = 2.5;
printf("Enter Number of week:\n ");
scanf("g%", &no_week);
salarypaycode_1 = no_week * salary_perweek;
printf("Manager''s Salary is %g\n",(float)salarypaycode_1);
}
br mode ="hold"/>我的编码是找到雇员的薪水.所以变量不会打扰它第一,因为我还没有完成我的编码.它只是它的一部分,我坚持这一部分.公式无法运行并且无法获得结果.我可以知道错误在哪里吗?我无法解决.
br mode="hold" />My coding is find the salary pay for the employee. So the variable dont bother it 1st because i haven finished my coding. It just part on it, and i stuck on this part.The formula cant run and cant get the result. May i know where is the error? i cant figure it out.
推荐答案
我可以看到的问题.
格式说明符应为%g",而不是以下行中的"g%":
Problems that I could see.
Format specifier should be "%g" instead of "g%" in below line:
scanf("g%", &no_week);
您正在尝试通过以下行将floationg点值分配给整数:
You are trying to assign floationg point value to an integer by below line:
hour = 2.5;
此外,初始化某些变量也是一种好习惯:
Additionally, it''s a good practice to initialize certain variables:
float no_week = 0.0;
这篇关于-C编程错误-的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文