Tuesday

How database system of Drupal works ?

0 comments
In Drupal, each type of information has its own database table. For instance, the basic information about the nodes of your site are stored in the Node table, Comments and Users also have their own database tables, and roles, permissions, and other settings are also stored in database tables.
Read More ->>

Friday

History of c Language

1 comments

History of c Language

 
In computing, C  is a general-purpose programming language initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs. Its design provides constructs that map efficiently to typical machine instructions, and therefore it found lasting use in applications that had formerly been coded in assembly language, most notably system software like the Unix computer operating system.
C is one of the most widely used programming languages of all time, and there are very few computer architectures for which a C compiler does not exist.

Many later languages have borrowed directly or indirectly from C, including C#, D, Go, Java, JavaScript, Limbo, LPC, Perl, PHP, Python, and Unix's C shell. The most pervasive influence on these languages has been syntactical, and they tend to combine the recognizable expression and statement syntax of C with underlying type systems, data models, and semantics that can be radically different. C++ started as a preprocessor for C and is currently nearly a superset of C.

Before there was an official standard for C, many users and implementors relied on an informal specification contained in a book by Ritchie and Brian Kernighan; that version is generally referred to as "K&R" C. In 1989 the American National Standards Institute published a standard for C (generally called "ANSI C" or "C89"). The next year, the same specification was approved by the International Organization for Standardization as an international standard (generally called "C90"). ISO later released an extension to the internationalization support of the standard in 1995, and a revised standard (known as "C99") in 1999. The current version of the standard (now known as "C11") was approved in December of 2011.
Read More ->>

K&R C

1 comments

 K&R C

In 1978, Brian Kernighan and Dennis Ritchie published the first edition of The C Programming Language.[9] This book, known to C programmers as "K&R", served for many years as an informal specification of the language. The version of C that it describes is commonly referred to as K&R C. The second edition of the book[10] covers the later ANSI C standard.

K&R introduced several language features:

    standard I/O library
    long int data type
    unsigned int data type
    compound assignment operators of the form =op (such as =-) were changed to the form op= to remove the semantic ambiguity created by such constructs as i=-10, which had been interpreted as i =- 10 (decrement i by 10) instead of the possibly intended i = -10 (let i be -10)

Even after the publication of the 1989 C standard, for many years K&R C was still considered the "lowest common denominator" to which C programmers restricted themselves when maximum portability was desired, since many older compilers were still in use, and because carefully written K&R C code can be legal Standard C as well.

In early versions of C, only functions that returned a non-int value needed to be declared if used before the function definition; a function used without any previous declaration was assumed to return type int, if its value was used.

For example:

long some_function();
/* int */ other_function();

/* int */ calling_function()
{
    long test1;
    register /* int */ test2;

    test1 = some_function();
    if (test1 > 0)
          test2 = 0;
    else
          test2 = other_function();
    return test2;
}

The int type specifiers which are commented out could be omitted in K&R C, but are required in later standards.

Since K&R function declarations did not include any information about function arguments, function parameter type checks were not performed, although some compilers would issue a warning message if a local function was called with the wrong number of arguments, or if multiple calls to an external function used different numbers or types of arguments. Separate tools such as Unix's lint utility were developed that (among other things) could check for consistency of function use across multiple source files.

In the years following the publication of K&R C, several unofficial features were added to the language, supported by compilers from AT&T and some other vendors. These included:

    void functions (i.e. functions with no return value)
    functions returning struct or union types (rather than pointers)
    assignment for struct data types
    enumerated types

The large number of extensions and lack of agreement on a standard library, together with the language popularity and the fact that not even the Unix compilers precisely implemented the K&R specification, led to the necessity of standardization.
Read More ->>

ANSI C and ISO C

3 comments

 ANSI C and ISO C

During the late 1970s and 1980s, versions of C were implemented for a wide variety of mainframe computers, minicomputers, and microcomputers, including the IBM PC, as its popularity began to increase significantly.

In 1983, the American National Standards Institute (ANSI) formed a committee, X3J11, to establish a standard specification of C. X3J11 based the C standard on the Unix implementation; however, the non-portable portion of the Unix C library was handed off to the IEEE working group 1003 to become the basis for the 1988 POSIX standard. In 1989, the C standard was ratified as ANSI X3.159-1989 "Programming Language C". This version of the language is often referred to as ANSI C, Standard C, or sometimes C89.

In 1990, the ANSI C standard (with formatting changes) was adopted by the International Organization for Standardization (ISO) as ISO/IEC 9899:1990, which is sometimes called C90. Therefore, the terms "C89" and "C90" refer to the same programming language.

ANSI, like other national standards bodies, no longer develops the C standard independently, but defers to the international C standard, maintained by the working group ISO/IEC JTC1/SC22/WG14. National adoption of an update to the international standard typically occurs within a year of ISO publication.

One of the aims of the C standardization process was to produce a superset of K&R C, incorporating many of the unofficial features subsequently introduced. The standards committee also included several additional features such as function prototypes (borrowed from C++), void pointers, support for international character sets and locales, and preprocessor enhancements. Although the syntax for parameter declarations was augmented to include the style used in C++, the K&R interface continued to be permitted, for compatibility with existing source code.

C89 is supported by current C compilers, and most C code being written today is based on it. Any program written only in Standard C and without any hardware-dependent assumptions will run correctly on any platform with a conforming C implementation, within its resource limits. Without such precautions, programs may compile only on a certain platform or with a particular compiler, due, for example, to the use of non-standard libraries, such as GUI libraries, or to a reliance on compiler- or platform-specific attributes such as the exact size of data types and byte endianness.

In cases where code must be compilable by either standard-conforming or K&R C-based compilers, the __STDC__ macro can be used to split the code into Standard and K&R sections to prevent the use on a K&R C-based compiler of features available only in Standard C.

Read More ->>

C99

0 comments

 C99


After the ANSI/ISO standardization process, the C language specification remained relatively static for several years. In 1995 Normative Amendment 1 to the 1990 C standard was published, to correct some details and to add more extensive support for international character sets. The C standard was further revised in the late 1990s, leading to the publication of ISO/IEC 9899:1999 in 1999, which is commonly referred to as "C99". It has since been amended three times by Technical Corrigenda.[11]

C99 introduced several new features, including inline functions, several new data types (including long long int and a complex type to represent complex numbers), variable-length arrays, improved support for IEEE 754 floating point, support for variadic macros (macros of variable arity), and support for one-line comments beginning with //, as in BCPL or C++. Many of these had already been implemented as extensions in several C compilers.

C99 is for the most part backward compatible with C90, but is stricter in some ways; in particular, a declaration that lacks a type specifier no longer has int implicitly assumed. A standard macro __STDC_VERSION__ is defined with value 199901L to indicate that C99 support is available. GCC, Solaris Studio, and other C compilers now support many or all of the new features of C99.
Read More ->>

Embedded c

1 comments

 Embedded c

Historically, embedded C programming requires nonstandard extensions to the C language in order to support exotic features such as fixed-point arithmetic, multiple distinct memory banks, and basic I/O operations.

In 2008, the C Standards Committee published a technical report extending the C language to address these issues by providing a common standard for all implementations to adhere to. It includes a number of features not available in normal C, such as fixed-point arithmetic, named address spaces, and basic I/O hardware addressing.
Read More ->>

Design

0 comments

                                               Design


C is an imperative (procedural) language. It was designed to be compiled using a relatively straightforward compiler, to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. C was therefore useful for many applications that had formerly been coded in assembly language, such as in system programming.

Despite its low-level capabilities, the language was designed to encourage cross-platform programming. A standards-compliant and portably written C program can be compiled for a very wide variety of computer platforms and operating systems with few changes to its source code. The language has become available on a very wide range of platforms, from embedded microcontrollers to supercomputers.
Read More ->>

Characteristics

0 comments

                                           Characteristics

Like most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. In C, all executable code is contained within subroutines, which are called "functions" (although not in the strict sense of functional programming). Function parameters are always passed by value. Pass-by-reference is simulated in C by explicitly passing pointer values. C program source text is free-format, using the semicolon as a statement terminator and curly braces for grouping blocks of statements.

The C language also exhibits the following characteristics:

    There is a small, fixed number of keywords, including a full set of flow of control primitives: for, if/else, while, switch, and do/while. There is basically one namespace, and user-defined names are not distinguished from keywords by any kind of sigil.
    There are a large number of arithmetical and logical operators, such as +, +=, ++, &, ~, etc.
    More than one assignment may be performed in a single statement.
    Function return values can be ignored when not needed.
    Typing is static, but weakly enforced: all data has a type, but implicit conversions can be performed; for instance, characters can be used as integers.
    Declaration syntax mimics usage context. C has no "define" keyword; instead, a statement beginning with the name of a type is taken as a declaration. There is no "function" keyword; instead, a function is indicated by the parentheses of an argument list.
    User-defined (typedef) and compound types are possible.
        Heterogeneous aggregate data types (struct) allow related data elements to be accessed and assigned as a unit.
        Array indexing is a secondary notion, defined in terms of pointer arithmetic. Unlike structs, arrays are not first-class objects; they cannot be assigned or compared using single built-in operators. There is no "array" keyword, in use or definition; instead, square brackets indicate arrays syntactically, e.g. month[11].
        Enumerated types are possible with the enum keyword. They are not tagged, and are freely interconvertible with integers.
        Strings are not a separate data type, but are conventionally implemented as null-terminated arrays of characters.
    Low-level access to computer memory is possible by converting machine addresses to typed pointers.
    Procedures (subroutines not returning values) are a special case of function, with an untyped return type void.
    Functions may not be defined within the lexical scope of other functions.
    Function and data pointers permit ad hoc run-time polymorphism.
    A preprocessor performs macro definition, source code file inclusion, and conditional compilation.
    There is a basic form of modularity: files can be compiled separately and linked together, with control over which functions and data objects are visible to other files via static and extern attributes.
    Complex functionality such as I/O, string manipulation, and mathematical functions are consistently delegated to library routines.

C does not include some features found in newer, more modern high-level languages, including object orientation and garbage collection.
Read More ->>

Early development

0 comments
Ken Thompson and Dennis Ritchie, developers of the C programming language.

The initial development of C occurred at AT&T Bell Labs between 1969 and 1973;[3] according to Ritchie, the most creative period occurred in 1972. It was named "C" because its features were derived from an earlier language called "B", which according to Ken Thompson was a stripped-down version of the BCPL programming language.

The origin of C is closely tied to the development of the Unix operating system, originally implemented in assembly language on a PDP-7 by Ritchie and Thompson, incorporating several ideas from colleagues. Eventually they decided to port the operating system to a PDP-11. B's inability to take advantage of some of the PDP-11's features, notably byte addressability, led to the development of an early version of C.

The original PDP-11 version of the Unix system was developed in assembly language. By 1973, with the addition of struct types, the C language had become powerful enough that most of the Unix kernel was rewritten in C. This was one of the first operating system kernels implemented in a language other than assembly. (Earlier instances include the Multics system (written in PL/I), and MCP (Master Control Program) for the Burroughs B5000 written in ALGOL in 1961.)
Read More ->>

Wednesday

What is the difference between union and structure?

0 comments
Q)What is the difference between union and structure?

Answer)

                       Structure                                                                                            
             1.We can access all the members of  structure at anytime 
                        Union  
             1.Only One member Can be accessed at anytime


                       Structure 
             2.Memory is allocated for all variables
                       Union                               
             2.Allocates memory for variable whichVariable
                 require more memory

                         Structure
            3.All members of Structur can be initialized
                         Union                          
            3.Only the first member of a union can be   
               initialized


                          Structure 
           4."Struct"   Keyword is Used to declare   structure
                         Union                             
           4."union" Keyword is used to declare union
           


                           Structure 
           5.All member has its own storage location
                           Union                         
           5.All members are stored in same location



Read More ->>

Tuesday

Bitwise operators

0 comments

Bitwise operators

The smallest element in memory on which are able to operate is called byte; and the programming language are byte oriented. One of the c powerful features is a set of bit manipulation operators. There are various bitwise operators in C as following table; we learn all step by step :

Operators    Name
&                Bitwise AND
|                  Bitwise OR
^                 Bitwise XOR(exclusive OR)
>>               Left shift
<<               right shift
~                 One's complement


These operators can operate upon ints and chars but not on floats and doubles. Bits are numbered from zero onwards, increasing from right to left as following figure:

7    6    5    4    3    2    1    0
8 bit Character


16    15    14    13    12    11    10    9    8    7    6    5    4    3    2    1    0
16 bit Integer


 Bitwise AND Operator (&)


The & operator operates on a pair of bits to yield a resultant bit. The rules that decide the value of the resultant bit also called truth table are shown below:

Bit x    Bit y    x & y
0          0            0
0          1            0
1          0            0
1          1            1

The best use of the AND operator is to check whether a particular bit of an operand is ON or OFF. The meaning of ON means 1 and OFF means 0. The following program puts this logic clear:

 /*Example of bitwise AND operator*/

 #include<stdio.h>
 #include<conio.h>
 void main()
 {
  int x=45;
  int y=37;
  int z;
  clrscr();
  z = x & y;
  printf("\nValue of z=%d",z);
 }



 Output of above program:

 Value of z=37


In above program compiler first calculate the binary x and y which is 111101 and 100101 respectly. After this its work on bitwise operator and final result is 37 which binary code are 100101. The following table shown the result : 

Values    binary code
x = 45    111101
y = 37    100101
z = x & y    100101

   Bitwise OR ( | )


Truth table for bitwise OR are as following :
x    y    z = x | y
0    0    0
0    1    1
1    0    1
1    1    1

  Bitwise XOR ( ^ )


It is also called exclusive OR. If there are similar bit then its return 0 otherwise its return 1. Let watch truth table of  x^y :
x    y    z = x ^ y
0    0    0
0    1    1
1    0    1
1    1    0
Example of exclusive OR :
x = 75
y = 64
z = x ^ y

 x = 1 0 0 1 0 1 1
 y = 1 0 0 0 0 0 0
 z = 0 0 0 1 0 1 1
 
hence, the value of z=11

Bitwise right shift ( >> )


Right shift operator shifts each bit in its left operand to the right. The number of places the bits are shifted depends on the number following the operator i.e. its right operand.
In simple meaning of bitwise right shift as :

            insertion(zero)  >  deletation

Example of right shift operator :
x = 15
y = x >> 2

[x=15 before right shifting ]         0000         0000      0000      1111
[y = x >> 2 during right shifting]  000000      0000      0000       1111
[y = x >> 2 after right shifting]     0000          0000      0000       0011

so now value of y=3.

Left Shift operator ( << )


This is similar to the right shift operator, the only difference being that the bits are shifted to the left, and for each shifted, a 0 is added to the right of the number. Following structure shows it :

  deletatio   >  insertion(zero)  

Example of right shift operator :
x = 15
y = x << 2

[x=15 before right shifting ]            0000  0000  0000  1111
[y = x << 2 during right shifting]     0000  0000  0000  111100
[y = x << 2 after right shifting]        0000  0000  0011  1100


so now value of y=60.

One's complement ( ~ ) or Tilde


It is reverse the bit i.e. if bit is 0 then its return 1 and when bit is 1 it is return 0.
example of tilde:
x = 15
y = ~ x

(15)10 = 0000 0000 0000 1111
y = ~ x   1111 1111 1111 0000
hense, 65535 - 15 = 65520.
so the value of y is 65520. 


Read More ->>

Monday

Pointer to union in c programming

0 comments

Pointer to union in c programming


Pointer to structure: A pointer which is pointing to a structure is know as pointer to structure.

Examples of pointers to structure:

1.What will be output if you will execute following code?

            #include<stdio.h>

             union address{

             char *name;

             char street[10];

             int pin;

          };

             int main(){

             union address emp,*p;

             emp.name="ja\0pan";

             p=&emp;

            printf("%s %s",p->name,(*p).name);

           return 0;

       }
Output: ja ja

Explanation:

p is pointer to union address.

-> and (*). Both are same thing. These operators are used to access data member of union by using union’s pointer.

%s is used to print the string up to null character i.e. ‘\0
Read More ->>

C programing index

5 comments

1.History of c programing language
·                     History of c language
·                     Early developments
·                     K&R C
·                     ANSI C and ISO C
·                     C99
·                     C11
·                     Embedded C
·                     Design
·                     Characteristic

2. Procedure for installing c software
·                     How to install c software
3. Elements of C
·                     What is c language
·                     Variables
·                     Keywords 
·                     Constant 
·                     Data types in c 
·                     Compilation and execution 


5.little endian and big endian

·                     little & big endian

6.C operators

·                     what is operators
·                     Logical operators
·                     Bitwise operators
·                     Arithmetic operators
·                     Relational operators
·                     Sizeof operators
·                     Increment or Decrement operators
·                     Comma operators
·                     Type cast operator

7.memory layout in c

·                     memory layout

8.Control statements

·                     Compound statement or block
·                     If statement
·                     Nesting of if,,
·                     Nested if else
·                     For loop
·                     Loops
·                     Nesting of loops
·                     Do while
·                     Break statement
·                     Continue statement
·                     Goto 
·                     Switch 
·                     9,storage classes 

10.Function

·                     What is functions 
·                     Function definitions
·                     Function call
·                     Function prototype
·                     Function arguments
·                      Recursionfunction   

11.array

·                     Whar is array
·                     One dimensional array
·                     Arrays and functions 

12. pointer

·                     What is pointer
·                     Null pointer
·                     Pointer to pointer
·                     Passing pointer to a function
·                     Array of pointer
·                     Function pointer
·                     wild,dagling,near,far and huge pointer
·                     Pointer to structure in c programming
·                     Pointer to union in c programming
·                     pointer to two,three dimensional array 
·                     Pointer to array of pointer to string
·                     pointer to array of character,array of array and array of interger

13.structure&union

·                     structure
·                     Array in structure
·                     Struture with in array
·                     Structure with in structure
·                     Structure padding 
·                     Union 

14.dyanamic memory allocation

·                     allocation memory dynamically 
·                     mollac ,collac ,realloc and free

15.String

·                     String in c
·                     Sscanf and sprint
·                     command line arguments

16.files handling

·                     opening closing reading writing


Read More ->>
 

| C programing tutorials © 2009. All Rights Reserved | Template Style by My Blogger Tricks .com | Design by Brian Gardner | Back To Top |