Program to define a function that returns structure:
#include<stdio.h> struct Emp { int id; char name[20]; float salary; }; struct Emp collect(); int main() { struct Emp y; y = collect(); printf(“Emp id : %d \n”, y.id); printf(“Emp name : %s \n”, y.name); printf(“Emp salary : %f \n”, y.salary); return 0; } struct Emp collect() { struct Emp x = {101, “Amar”, 35000}; return x; } |