c language

It's all about self learning.


In the C programming language, data types refer to an extensive system used for declaring variables or functions of different types. The type of a variable determines how much space it occupies in storage and how the bit pattern stored is interpreted. A program usually contains different types of data types (integer, float, character etc.) and need to store the values being used in the program. All C compilers support four data types, namely int , char, float, double. The types in C can be classified as follows:
19 July, 2016     
In a C-programming, Programmers can defined its own data-types.There are two  types varities in User defined Data-types given as below.
       (1) Typedef
       (2) Enumerated (Enum)

    Type def data Types:   typedef is a reserved Keyword in the C It is used to create an alias name for another data types. it is often used to simplify the syntax of declaring complex data types , but is just as common in providing specific descriptive type names for integer data types of varying length.
The user defined data type identifier can later be used to declare variables. It takes the general form:  typedef type identifier,Where type refers to an existing data type and “identifier” refers to the “new” name given to the data type. The existing data type may belong to any class of type, including the user- defined ones . Remember that the new type is”new” only in name, but not the data type.
Typedef  cannot create a new type. Some examples of type definitions are:
  Typedef int units;
Typedef float marks;
typedef struct employee
 char  name[50];
 int   salary;
} emp ;
void main( )
 emp e1;
 printf("\nEnter Employee record\n");
 printf("\nEmployee name\t");
 printf("\nEnter Employee salary \t");
 printf("\nstudent name is %s",;
 printf("\nroll is %d",e1.salary);

ENUMIn c programming, an enumerated type (also called enumeration or enum) is a data type consisting of a set of named values called elements, members, enumeral, or enumerators of the type. The enumerator names are usually identifiers that behave as constants in the language.

 An enumerated type can be seen as a degenerate tagged union of unit type.
 A variable that has been declared as having an enumerated type can be assigned any of the enumerators as a value.
 In other words, an enumerated type has values that are different from each other, and that can be compared and assigned, but are not specified by the programmer as having any particular concrete representation in the computer's memory; 
 compilers and interpreters can represent them arbitrarily.
DECLARATION:      enum type_name{ value1, value2,...,valueN };


enum week{ sunday, monday, tuesday, wednesday, thursday, friday, saturday};
int main(){
    enum week today;
    printf("%d day",today+1);
    return 0;

The compiler automatically assigns integer digits beginning with 0 to all the enumeration constants . 
value1 is assigned 0, value2 is assigned 1..and so on.
                                          Enum day{ Monday=1, Tuesday=2..}
The definition and declaration of enumerated variables can be combined in one statement , 
Example: enum day {Monday, ..Sunday} week_st, week_end.

For programs please click
no copyrights issue

Get solution for your websites