structure

/* This program prints Hello on Console Screen */

#include<stdio.h>
void main()
{
     printf("hello world");
}

Comments:
In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program.Comments are statements that are not executed by the compiler and interpreter. All the comments will be put inside /*...*/ as given in the example above. A comment can span through multiple lines.

#include<stdio.h>
These commands tells the compiler to do preprocessing before doing actual compilation. Like #include <stdio.h> is a preprocessor command which tells a C compiler to include stdio.h file before going to actual compilation.

void main()
This is the main function, which is the default entry point for every C program and the void in front of it indicates that it does not return a value.

{...}
Curly braces which shows how much the main() function has its scope.

printf("hello world");
The C Programming language provides a set of built-in functions. In the above example printf() is a C built-in function which is used to print anything on the screen.

In Array we can store data of one type only, but structure is a variable that gives facility of storing data of different data type in one variable.

Structures are variables that have several parts; each part of the object can have different types.
Each part of the structure is called a member of the structure.

# Declaration 

Consider basic data of student :
roll_no, class, name, age, address.

A structure data type called student can hold all this information:
struct student {
int roll_no
char class
char name[25];
int age;
char address[50];
};

before the final semicolon, At the end of the structure's definition, we can specify one or more structure variables.

There is also another way of declaring variables given below,
struct student s1;

# Initialization

Structure members can be initialized at declaration. This is same as the initialization of arrays; the values are listed inside braces. The structure declaration is preceded by the keyword static.

static struct student akki ={1234,''comp'',''akki'',20,''mumbai''};

# Accessing structure details 

To access a given member the dot notation is use. The ''dot'' is called the member access operator

struct student s1;
s1.name = ''Akki'';
s1.roll_no = 1234

scope 

A structure type declaration can be local or global, depending upon where the declaration is made.

Comments

Popular posts from this blog

STRUCTURE

FILE HANDLING

WHILE LOOP