TOP CRICKETER HOUSE PRICE

Image
TOP CRICKETERS HOUSE IN THE WORLD RICKY POINTING 69.8 CRORE SHANE WATSON  62.8 CRORE YUVRAJ SINGH 60 CRORE MICHEAL CLARKE 59.3 CRORE DAVID WARNER 45.3 CRORE SHANE WARNE 38.4 CRORE SACHIN TENDULKAR 38 CRORE VIRAT KOHLI HOUSE 34 CRORE ROHIT SHARMA 30CR BRETT LEE HOUSE  27.9 CRORE

C STRUCTURED DATA TYPE



Structure Example:

Try out following example to understand the concept:
#include <stdio.h>
struct student {
    char firstName[20];
    char lastName[20];
    char SSN[10];
    float gpa;
};

main()
{
  struct student student_a;

  strcpy(student_a.firstName, "Deo");
  strcpy(student_a.lastName, "Dum");
  strcpy(student_a.SSN, "2333234" );
  student_a.gpa = 2009.20;

 printf( "First Name: %s\n", student_a.firstName );
 printf( "Last Name: %s\n", student_a.lastName );
 printf( "SNN : %s\n", student_a.SSN );
 printf( "GPA : %f\n", student_a.gpa );
}
This will produce following results:
First Name: Deo
Last Name: Dum
SSN : 2333234
GPA : 2009.20

Pointers to Structs:

Sometimes it is useful to assign pointers to structures (this will be evident in the next section with self-referential structures). Declaring pointers to structures is basically the same as declaring a normal pointer:
struct student *student_a;
To dereference, you can use the infix operator: ->.
printf("%s\n", student_a->SSN);

typedef Keyword

There is an easier way to define structs or you could "alias" types you create. For example:
typedef struct{
    char firstName[20];
    char lastName[20];
    char SSN[10];
    float gpa;
  }student;
Now you can use student directly to define variables of student type without using struct keyword. Following is the example:
student student_a;
You can use typedef for non-structs:
typedef long int *pint32;

pint32 x, y, z;
x, y and z are all pointers to long ints

Unions Datatype

Unions are declared in the same fashion as structs, but have a fundamental difference. Only one item within the union can be used at any time, because the memory allocated for each item inside the union is in a shared memory location.
Here is how we define a Union

Comments

Popular posts from this blog

TECHNICAL INTERVIEW QUESTION

MS DHONI