Calculate month salary of an employee

C program that accepts an employee's ID, total worked hours of a month and the amount he received per hour. Print the employee's ID and salary (with two decimal places) of a particular month.

Program

#include<stdio.h>
#include<conio.h>
void main()
{
    char id[10];
	int hour;
	float value, salary;

	printf("Enter the Employees ID(Max. 10 chars): ");
	scanf("%s", &id);
	printf("Enter the working hrs: ");
	scanf("%d", &hour);
	printf("Enter the salary amount/hr: ");
	scanf("%f", &value);

	salary = value * hour;

	printf("\nEmployees ID = %s\nSalary = Rs. %.2f\n", id,salary);

	getch();
}

Output

Enter the Employees ID(Max. 10 chars): s12
Enter the working hrs: 23
Enter the salary amount/hr: 20

Employees ID = s12
Salary = Rs. 460.00

Explanation

In this program, to store the employee ID, a character array of size 10 is declared
char id[10];
Note that, %s format specifier is used for character array. Total working hours and salary per hour are also taken as an input from user in the variables named 'hour' and 'value' respectively.
Total salary of the employee is calculated using the formula
salary = value * hour;

By default, a float value is printed upto 6 decimal places.
For example,
float num = 34.45;
printf("%f",num);
output:
34.450000

we can customize the above output by telling how many digits are required after decimal. This can be done by modifying the format specifier. Instead of %f, %.nf is used, where n is the number of digits after decimal
printf("%.2f",num); In this, output will be displayed upto 2 decimal places.
output:
34.45

printf("%.4f",num)
In this output will be displayed upto 4 decimal places.
output:
34.4500