Structures, C/C++ Programming

Assignment Help:

  A more advanced data type is the structure; here we can define a template as a collection of different variables e.g.
 
  struct birthdate
  {
    int month;
    int day;
    int year;
  };
 
  Here the template birthdate consists of three separate content variables namely month   , day , year .We can access each part of the structure by means of the dot '.' operator i.e. after we have allocated the variable to be used to hold the structure.
 
    struct  birthdate john;
 
We can access all the details i.e.
 
      john.month  = 12;
      john.day = 28;
      john.year = 52;
 
This is identical to using a two dimensional array to hold the values
 
      john[0][0]  could hold month
      john[0][1]  could hold day
      john[1][0]  could hold year

However using a structure template we can use different types in the same structure
   
    struct details
    {
    int month;
    int day;
    int year;
    char * name;
    };
 
It is possible to use structures defined as pointers, if you wish to want to use the actual address.
 
  
    main()
    {
      struct *records 
      {
      int month;
      int day;
      int year;
      char * name;
      };
 
  Here we have a structure assigned to a pointer record. In order to access the content month we use must dereference the pointer and access the element i.e.
 
      (*records).month 
 
This is often replaced with a -> symbol (minus followed by >) i.e.
 
      records -> month.


Related Discussions:- Structures

Write a program to find the area under the curve y =, Write a program to fi...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.   #include float start_poin

When do employ "const" reference arguments in function?, A: 1.      By u...

A: 1.      By using const protects you against programming errors which inadvertently alter data. 2.      By using const allows function to procedure const and non-const actu

C program to create, Aim: To implement a program to create, update & displ...

Aim: To implement a program to create, update & display account & admin record of person using display account & admin records of person using virtual base class.. Code:

Program of libarary , #include #include using namespace std; class Book...

#include #include using namespace std; class Book { private: string title; int iD; int year_pub; string author; public: string getTitle(); int getId(); int getYear_Pub(); st

Programing project, Hello, Do you have any idea for programming project to...

Hello, Do you have any idea for programming project to simulate a network attack (threat) mechanism or a defense mechanism. Can I get some suggestions for this. Please include th

If/else statement, to compute the net pay of an emplyee, given his/her pay ...

to compute the net pay of an emplyee, given his/her pay rate, number of hours and tax rate

Define the relational operator in c language, Define the Relational Operato...

Define the Relational Operator in c language? The Relational operators refer to the relationships that values can have with one another and they are used to compare two operand

Template class and class template in c++, Differentiate between a template ...

Differentiate between a template class and class template in C++? Ans) Template class: A generic definition or a parameterized class not instantiated until the client gives the

C programs, 2. a) Define a structure to store roll no, name and marks of a ...

2. a) Define a structure to store roll no, name and marks of a student. b) Using the structure of Q2. a), above write a ''C'' program to create a file "student.dat". There must be

Microprocessors and motherboards, The heart of the modern electronic system...

The heart of the modern electronic system is the microprocessor e.g. the video, sound, game consoles, portable phones and domestic appliances. Let us consider the heart of a home c

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd