Knowee
Questions
Features
Study Tools

#include<stdio.h> struct employee{ char *empname; int salary;};int main(){ struct employee e, e1; e.empname = "Sridhar"; e1 = e; printf("%s %s", e.empname, e1.empname); return 0;}

Question

#include<stdio.h> struct employee{ char *empname; int salary;};int main(){ struct employee e, e1; e.empname = "Sridhar"; e1 = e; printf("%s %s", e.empname, e1.empname); return 0;}

🧐 Not the exact question you are looking for?Go ask a question

Solution

The code you've written is in C language. It defines a structure employee with two members: a character pointer empname and an integer salary.

In the main function, two variables e and e1 of type employee are declared. The empname of e is assigned the string "Sridhar". Then, e1 is assigned the value of e, which means all members of e are copied to e1.

Finally, the printf function is used to print the empname of both e and e1. Since e1 was assigned the value of e, both printf calls will output "Sridhar".

Here's the step-by-step breakdown:

  1. Define a structure employee with a character pointer empname and an integer salary.
  2. Declare two variables e and e1 of type employee.
  3. Assign the string "Sridhar" to empname of e.
  4. Assign e to e1, copying all members of e to e1.
  5. Print the empname of e and e1 using printf.
  6. Since e1 was assigned the value of e, both printf calls will output "Sridhar".

The output of the program will be: Sridhar Sridhar.

This problem has been solved

Similar Questions

0/0

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.