Computer Programming C Laboratory: Unions C Programs

C Program to print variables from memory address

Dynamic Memory Allocation - C Programming

C Program to print variables from memory address.

/* C Program to print variables from memory address */

#include <stdio.h>

#include <stdlib.h>

#include <conio.h>

void main()

{

int *a, *n, size;  /* *a, *n is a pointer variables */

printf("Enter the size...");

scanf("%d", &size);

n = (int *)malloc(size * sizeof(int));

/* malloc() function allocate he memory size to the given variables */

printf("Address of the first byte is.... %u\n", n);

printf("Enter the values...");

for(a=n; a <n+size; a++)

scanf("%d", a);

printf("Printing the values...\n");

for(a=n+size‒1;a> =n;a‒‒)

printf("%d is stored in address %u\n", *a, a);

} /* main */

OUTPUT

Enter the size...5

Address of the first byte is....1952

Enter the values...1 2 3 4 5

Printing the values...

5 is stored in address 1960

4 is stored in address 1958.

3 is stored in address 1956

2 is stored in address 1954

1 is stored in address 1952

EXPLANATION: The sizeof() function determines the size of data type required to store for that data type. The malloc() function determine the memory to allocate that size of the variable.

Computer Programming C Laboratory: Unions C Programs : Tag: C Programming : - C Program to print variables from memory address


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