Click here to Skip to main content
16,020,677 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
#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" />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.
Posted

1 solution

Problems that I could see.
Format specifier should be "%g" instead of "g%" in below line:
scanf("g%", &no_week);

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;
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 16-Mar-11 20:09pm    
OK, a 5.
--SA
Ozer Karaagac 16-Mar-11 20:28pm    
Thank you, --SA.
Jayfam 17-Mar-11 0:53am    
Thanx Ozer..error solve

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900