Computer Programming C Laboratory: Structures C Programs

Structure within structure in C using normal variable

Using Structure - C Programming


This program explains how to use structure within structure using normal variable. "college_detail' structure is declared inside "student_detail" structure in this program. Both structure variables are normal variables.

Please note that members of "college_detail" structure are accessed by 2 dot(.) operator and members of "student detail" structure are accessed by single dot(.) operator.

#include <stdio.h>

#include <string.h>

struct college_detail

{

int college_id;

char college_name[50];

};

struct student_detail

{

intsno;

char name[20];

float percentage;

/*structure within structure*/

struct college_detail_clg_data;

} stu_data;

int main()

{

struct student_detail stu_data = {1, "Mahi", 98.5, 13813, "Anna University"};

printf("Sno is: %d\n", stu_data.sno);

printf("Name is: %s\n", stu_data.name);

printf("Percentage is: %f\n\n", stu_data.percentage);

printf("College Id is: %d\n", stu_data.clg_data.college_id);

printf("College Name is: %s\n", stu_data.clg_data.college_name);

return 0;

}

OUTPUT

Sno is : 1

Name is : Mahi

Percentage is : 98.500000

College Id is : 13812

College Name is : Anna University

Sno is : 2

Name is : Karthik

Percentage is : 99.500000

College Id is : 13313

College Name is : Anna University

Sno is : 3

Name is : Roshan

Percentage is : 96.500000

College Id is: 13413

College Name is: Anna University

Sno is: 4

Name is : Muni

Percentage is : 98.500000

College Id is : 17776

College Name is: Anna University


Computer Programming C Laboratory: Structures C Programs : Tag: C Programming : - Structure within structure in C using normal variable


Computer Programming C Laboratory: Structures C Programs



Under Subject


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation



Related Subjects


English Essentials I

EN25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


தமிழர் மரபு - Heritage of Tamils

UC25H01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Calculus

MA25C01 Maths 1 M1 - 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I

PH25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Applied Chemistry I

CY25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Makerspace

ME25C04 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming C

CS25C01 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Computer Programming Python

CS25C02 1st Semester | 2025 Regulation | 1st Semester 2025 Regulation


Fundamentals of Electrical and Electronics Engineering

EE25C03 1st Semester EEE Depart | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Mechanical Engineering

ME25C03 1st Semester Mechanical Dept | 2025 Regulation | 1st Semester 2025 Regulation


Introduction to Civil Engineering

CE25C01 1st Semester Civil, Agri Departments | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing

CS25C03 1st Semester - AIDS, CSE, CSE(CY), IT Department | 2025 Regulation | 1st Semester 2025 Regulation


Applied Physics I Laboratory

PH25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Applied Chemistry I Laboratory

CY25C01 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming C Laboratory

CS25C01 1st Semester EEE, ECE, CSE, CSE(CY), AIDS, IT practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Computer Programming Python Laboratory

CS25C02 1st Semester practical Laboratory Manual | 2025 Regulation | 1st Semester Laboratory 2025 Regulation


Engineering Drawing

ME25C01 EEE, Mech, Agri, EEE Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electronics and Electrical Engineering

EE25C04 1st Semester ECE Dept | 2025 Regulation | 1st Semester 2025 Regulation


Essentials of Computing - Laboratory

CS25C03 1st Semester AIDS, CSE, CSE(CY), IT Depts | practical Laboratory Manual | 2025 Regulation | 1st Semester 2025 Regulation