c code for struture

  • cstructurefunctions
  • create a structure named Company with deatils of it.

    write a prog to create a structure named Company with a name, address, phone, and no of Employee as a member variable. Read and display all these member variables.

    Code

    #include <stdio.h> #include <stdlib.h> #include <string.h> struct company{ char name[50]; char adress[50]; int phone_number; int no_of_employee; }; void setval(struct company* a){ printf("enter the name\n"); scanf("%[^\n]",a->name); getchar(); printf("enter the adress\n"); scanf("%[^\n]",a->adress); printf("enter the phone number\n"); scanf("%d",&a->phone_number); printf("enter the no of employee\n"); scanf("%d",&a->no_of_employee); } void display(struct company* a){ printf("company name : %s\n",a->name); printf("company address : %s\n",a->adress); printf("company number : %d\n",a->phone_number); printf("company no of employee : %d\n",a->no_of_employee); } int main(){ struct company x; setval(&x); display(&x); return 0; }