C Programming language

adplus-dvertising
About C

In this section we are going to provide History, Advantage of C , Disadvantage of C, Identifier ,Keyword, printf(), Format Specifiers, and Commonly used escape sequences are with Examples.

Previous Home Next

History of C

C was developed at Bell Lab in 1972 by Dennis Richie ..CPL(Combined Programming Language) was developed with The purpose of High Level language n machine independent language but draw back of CPL is too longer code so that BCPL (Basic CPL ) was developed .

In 1970 B language was developed by the Ken Thomson had adopt the feature of BCPL and in 1972 Co-Worker of Ken Thomson Dennis Ritchie developed C .

Advantage of C

  • C code are optimized so its small and very efficient.
  • C has which is its application in Firmware programming (hardware). C language ability it is use/work with assembly and communicates directly with controllers, processors and other devices.

Disadvantage of C

  • C have no concept of runtime checking.
  • C have no concept of no strict type checking.

Example

An integer value can be pass for the floating data type.


float main()
{
float a;
a=3;//here an error but it not detected..
return a;
}

As the program extends it is very difficult to fix the bugs.

Identifier

In C, an identifier is the combination of alphabetic character; underline .An identifier is used for any variable, function, data definition etc.

In c the first character is an alphabetic character or an underline n remaining being any numeric digit, alphabet or underline. The significant character have only 31 character if its more then 31 then rest character may be ignored by any given compiler.

Example

  • Number-suggest that this variable store numeric value.
  • Most of the complier writer use variables first underscore and second character as capital letter so avoid this format.

Declaration Vs Definition

If we concerned about function declaration Vs definition in c .

In C prototyping of function is called declaration that tells the compiler to essentials of that function such as the its name, return type, and number and type of its parameters.

The function name, followed by the body of the function, defines the function .The function body contains set of statements, operators and local variables.

Example


int fun(int); //Declare
int fun(int){
//Define
...
}

If we concerned about variable declaration Vs definition in c .

In Register and auto variable there is no difference between declaration and definition.

but in external variable memory allocated once ,to ensure that access to the variable always refers to the same cell.

If an external variable if a variable is used in more then one file , then this variable needed to connect such a use with the uniquely defined that external variable cell allocated for it. This process of connecting the references of the same external variable in different files, is called resolving the references.

Keyword

C provides 32 keywords which can not use for other purpose.

auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while

printf()

printf ()function is a standard library function . printf () function is followed by a parenthesized list of argument . printf() is a library function that print output .


printf(" This is a c program \n");

"This is a c program \n"is the character string or string constant.

Format Specifiers

There are many format specifiers defined in C. Take a look at the following list below:

SignMeaning
%i or %d int
%c char
%ffloat
%lfdouble
%sstring

Commonly used escape sequences are:

SignMeaning
\nnewline
\t tab
\vvertical tab
\fnew page
\bbackspace
\r carriage return
Previous Home Next