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.