Question: Execute the following coding segment and identify the errors in the program. Debug the program and provide the correct version of the code. Note: The
Execute the following coding segment and identify the errors in the program. Debug the program and provide the correct version of the code. Note: The errors can be syntactical or logical.
#include
// employee structure definition
struct employee
{
unsigned int age;
char gender;
double hourlySalary;
}
int main(void)
{
Employee emp1; // define one struct employee variable
// Store values in the emp1
emp1. age = 20;
emp1. gender = M;
emp1.hourlySalary = 10;
printf(%s%d , emp1 age is:, emp1.age);
printf(%s%c , emp1 gender is:, emp1.gender);
printf(%s%.2f , emp1 hourly salary is:, emp1.hourlySalary);
return 0;
}
Execute the following coding segment and identify the errors in the program. Debug the program and provide the correct version of the code. Note: The errors can be syntactical or logical.
#include
// employee structure definition
struct employee
{
unsigned int age;
char gender;
double hourlySalary;
};
int main(void)
{
Employee emp1; // define one struct employee variable
// Store values in the emp1
emp1. age = 20;
emp1. gender = X;
emp1.hourlySalary = 10;
printf(%s%d , emp1 age is:, emp1.age);
printf(%s%c , emp1 gender is:, emp1.gender);
printf(%s%.2f , emp1 hourly salary is:, emp1.hourlySalary);
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
