Tech Study

C Struct : All structure in C programs with examples

Structure is user defined data type available in C programming language that allows to combine data items of different kinds.

“struct” keyword is used to create a structure in C programming language.

Structure is user defined data type available in C programming language that allows to combine data items of different kinds. Structures are used to represent a record. for example you want to keep track of student of a school.

Structre in C Programming

Define Structures

First we have to define the data type to ctreate sturcture variables. Struct keyword is used to define a structure.

Syntax of struct

struct structureName {
dataType member1;
dataType member2;
...
};

For example,

struct Person {
char name[50];
int citNo;
float salary;
};

 

C Struct Example

You might want to track the following attributes about each student −

  • Roll No
  • Name
  • Marks
struct student
{
    int roll;
    char name[50];   
    float marks;
}

I have used Code::blocks 12 compiler for debugging purpose. But you can use any C programming language compiler as per your.

C Struct : C Programming Examples for Structure Programes

  1. Write a C program to Store Information in Structure and Display it
  2. Write a C Program to add two distances in inch-feet system using Structure
  3. Write a C Program to Calculate Difference Between Two Time Periods
  4. Write a C program to demonstrate example of Nested Structure
  5. Write a C program to demonstrate example of structure pointer
  6. Write a C program to calculate percentage of student using structure
  7. Write a C program to create Book Details using structure

TaggedAll structure programs with examples

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more