Wednesday, September 19, 2018

Static Structure - Employee

  • Problem Description

    1. Create a Structure called "employee"

    2. Create three data members as name(char), empid(int), salary(float)

    3. Input the value of employee's (name, empid and salary)

    4. Create Structure Variable as "emp"

    5. Display using structure variable.datamember

    Hint:
    emp.name

    Note: The structure variables, data members and structure name are CASE Sensitive.

    Follow the same case mentioned in the mandatory
  • CODING ARENA
  • #include <stdio.h>
     

    struct employee{
        char    name[30];
        int     empId;
        float   salary;
    };
     
    int main()
    {
     
        struct employee emp;
         

               scanf("%s",emp.name);
                 scanf("%d",&emp.empId);
             scanf("%f",&emp.salary);
         
        printf("%s\n"   ,emp.name);
        printf("%d\n"     ,emp.empId);
        printf("%.f\n",emp.salary);
        return 0;
    }
  • Test Case 1

    Input (stdin)
    Bogar
    
    1122
    
    15000
    
    
    Expected Output
    Bogar
    
    1122
    
    15000
  • Test Case 2

    Input (stdin)
    Naveen
    
    4422
    
    20000
    
    
    Expected Output
    Naveen
    
    4422
    
    20000

No comments:

Post a Comment