Computer Programming C Laboratory: Unions C Programs

Write a C program to print name, and address using structure

C Programs using Structures & Unions

Write a C program to print name, and address using structure.

/* Program to print name, and address */

#include <stdio.h>

#include<conio.h>

struct address /* structure declaration */

{

       char plot[30]; /* members */

       char street[30];

       char city[30];

};

struct student /* structure declaration */

{

       char name[30]; /* members */

       int marks;

       struct address adr;

};

void main()

{

struct student class[5]; /* Local definitions*/

/* statements "/

clrscr();

printf("Enter Name: ");

scanf("%s", class[1].name);

printf("Enter Marks: ");

scanf("%d", &class[1]. marks);

printf("Enter Plot Number: ");

scanf("%s", class[1].adr.plot);

printf("Enter Street name: ");

scanf("%s", class[1].adr. street);

printf("Enter City Name : ");

scanf("%s", class[1].adr.city);

printf("\n");

printf("Name is : %s\n", class[1].name);

printf("Marks are%d\n", class[1].marks);

printf("Plot Number is: %s\n", class[1].adr.plot);

printf("Street: : %s\n", class[1].adr.street);

printf("City is %s\n", class[1].adr.city);

getch();

} /* main */.

OUTPUT

Enter Name : Mahi

Enter Marks : 89

Enter Plot Number : 68

Enter Street name : 24

Enter City Name : Chennai

Name is : Mahi

Marks are : 89

Plot Number is : 68

Street : 24

City is : Chennai

EXPLANATION: This program illustrates the concept of nested structure and inputting values for two different structure member and printing their contents.

Computer Programming C Laboratory: Unions C Programs : Tag: C Programming : - Write a C program to print name, and address using structure


Computer Programming C Laboratory: Unions 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