Click here to Skip to main content
15,042,088 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
Fill in the missing code in the below program to read an employee gender,age and salary from standard input and prints same to the standard output.
#include <stdio.h>
void main() {
    char gender;
    short int age;
    float salary;
    printf("Enter an employee gender (M/F), age, salary : ");
    printf("Employee gender is : \n", );
    printf("Employee age is : \n", );
    printf(Employee salary is : \n", );

What I have tried:

#include <stdio.h>
void main() {
    char gender;
    short int age;
    float salary;
    printf("Enter an employee gender (M/F), age, salary : ");
    scanf("%c, %d, %f", &gender, &age, &salary)
    printf("Employee gender is : %c\n", gender);
    printf("Employee age is : %d\n", age);
    printf(Employee salary is : %f\n", salary);
Updated 21-Feb-21 0:42am
CPallini 26-Jul-18 5:43am
It looks you've tried nothing.

So, you show no attempt to solve the problem yourself, you have no question, you just want us to do your HomeWork.
HomeWork problems are simplified versions of the kind of problems you will have to solve in real life, their purpose is learning and practicing.
We do not do your HomeWork.

HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
Any failure of you will help you to learn what works and what don't, it is called 'trial and error' learning.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.
Just compile it and inspect the error and warning messages. Note that the messages inform you about the line number and the column where the compiler detected a problem (here using GCC as example).

test.c:2:6: warning: return type of ‘main’ is not ‘int’
main() should return an int:
int main()
    /* code goes here*/
    return 0;

test.c:7:1: warning: format ‘%d’ expects type ‘int *’, but argument 3 has type ‘short int *’
You have to use the h prefix for short integers:
//scanf("%c, %d, %f", &gender, &age, &salary)
scanf("%c, %hd, %f", &gender, &age, &salary);

test.c:8:1: error: expected ‘;’ before ‘printf’
There is a semicolon missing at the end of the previous line (see above; I have added it there already).

test.c:10:8: error: ‘Employee’ undeclared (first use in this function)
... (more errors on line 10)
There is a double quote missing on that line:
//printf(Employee salary is : %f\n", salary);
printf("Employee salary is : %f\n", salary);
Member 13926455 26-Jul-18 6:21am
Thank you so much for the help!!

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