Lesson 22 of 23

Structures (struct)

11 min 35 XP

struct വ്യത്യസ്ത types-ലുള്ള fields ഒരു പുതിയ type ആയി കൂട്ടുന്നു, വിദ്യാർത്ഥിയുടെ പേര്, roll number, മാർക്ക് എന്നിവ പോലെ. typedef അതിന് ചെറിയ പേര് നൽകുന്നു, -> pointer വഴി field-ൽ എത്തുന്നു.

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

struct vs union: union-ൽ എല്ലാ fields-ഉം ഒരേ memory പങ്കിടുന്നു. C interviews-ൽ ഈ ചോദ്യം പ്രതീക്ഷിക്കൂ.

Challenge

+35 XP

n വായിക്കൂ, പിന്നെ n വിദ്യാർത്ഥികളുടെ പേരും മാർക്കും (int). അവ structs-ന്റെ array-യിൽ സൂക്ഷിച്ച് topper-ഉം ക്ലാസ് ശരാശരിയും print ചെയ്യൂ. Input: 3 Arun 78 Bala 95 Charu 88 Output: Topper: Bala 95 Average: 87.00

Output Loading C (first time takes a few seconds)
Press Run to see the result here.