About C Programming

Updated on June 20, 2013

The C programming language is the foundation of C++. In fact, C is the basis of many modern languages, including Java, JavaScript, Perl, PHP, Python and many, many others. Of course, C++ and Objective-C are direct descendents of C and include the entire C language. Yes, the entire C language is included in the definition of C++ and learning C is an essential first step on the road to learning C++. Let me say this again in a deferent way. You can not skip this step. In order to learn C++, you must first learn C.

Developed by Dennis Ritchie at Bell Labs in 1969, C was designed as an alternative to assembly language for creating operating systems utilities and other systems level code. C is a small language with only 32 keywords. It's not what we would call today a high-level language. It is small, efficient, fast, and powerful. If you consider layers of technology in a computer system as a stack, C is commonly used to write code at all levels, with its most common usage at the lower levels. Almost all firmware, almost all modern operating systems and a great deal of application software is written in C.

About C++C++ was developed in the late 1970s by the Danish computer scientist, Bjarne Stroustrup. Learn Something About C++.

Why is C so popular?

Systems code written in C tends to be small and fast, well-written C can generate object code that is almost a small and fast as code written in assembly language. Code written in C is extremely portable. C was originally designed for writing operating systems. For example, the UNIX operating system was written in C, and it runs on many, many different processors and hardware configurations. This is possible because so much of the operating system compiles and runs on many different machines, architectures and processors with little or no modification to the source code. This is equally true of applications written in C. The language itself is relatively small and easy to learn, yet its simplicity is deceptive. It gives you such access to the machine that is actually very rich and powerful language.

Source

Rate Me!

4.5 out of 5 stars from 2 ratings of Programming C

C is a low-level language that means that it's close to the machine. It doesn't have a lot of features, but it compiles to tight, fast, efficient code that's what's C is good at, that's why people continue to use C after over 40 years. C is an imperative language. This means that the code is described as statements, subroutines are called functions and arguments are always passed by value. C is a block-oriented structured language that is code happens in blocks and the blocks are structured to enhance clarity. This is to improve quality and maintainability of your code. C is strongly typed; this means that each variable must have a declared type. Type declarations are parsed at compile time and they cannot change during the life of the variable.

The advantage of a strongly typed language is that performance is significantly improved over similar dynamically typed languages. In a dynamically typed system, runtime processing power is used to determine the type of a variable and create working copies with the appropriate data structures for every variable and even repeat these actions when a variable is changed. By determining the type of variable at compile time, all of this overhead is eliminated.

C Programming Tutorial - Hello World

The first written standard for the C programming language was a book called The C programming language by Brian W. Kernighan and Dennis M. Ritchie. The book came to be effectually known as K&R and the version of the language documented was called K&R C. The first edition of the book is long out of print; the revised version currently in print documents the next later version ANSI C. The ANSI C standard was ratified in 1989 and adopted by the ISO in 1990. So you'll see it referred to as both C89 and C90. The first truly standardized C, this version is the basis for most of the C we use today. ANSI C introduced function prototypes, void pointers and locals all of which are considered fundamental to C today.

C99 is mostly compatible with ANSI C with a few new features and a few tighter restrictions. Notable enhancements include C++ style one-line comments introduced by two forward slash characters and variables can be declared anywhere within a block instead of only at the top of a block. C11 is the latest standardized version, and it codifies features that have been implemented by many compilers, including a more detailed memory models for threaded code. Removal of the get function improved Unicode support, anonymous structures and unions and some optional features.

We use C11 but since most of the changes since ANSI C have been incremental, most of what you learn will apply to any standard C version. Because C is the foundation of C++ and the complete C language is included in the definition of C++.

C99 adds five more keywords:

_Bool

_Complex

_Imaginary

inline

restrict

C11 adds seven more keywords:

_Alignas

_Alignof

_Atomic

_Generic

_Noreturn

_Static_assert

_Thread_local

Keywords

The syntax of the C programming language, the rules governing writing of software in the language, is designed to allow for programs that are extremely terse, have a close relationship with the resulting object code, and yet provide relatively high-level data abstraction. The development of this syntax was a major milestone in the history of computer science as it was the first widely successful high-level language for operating-system development.C syntax makes use of the maximal munch principle.

C89 has 32 keywords (reserved words with special meaning):

auto

break

case

char

const

continue

default

do

double

else

enum

extern

float

for

goto

if

int

long

register

return

short

signed

sizeof

static

struct

switch

typedef

union

unsigned

void

volatile

while

Standard libraries by header

The API of the C standard library is declared in a number of header files. Each header file contains one or more function declarations, data type definitions, and macros.

Operators

C supports a rich set of operators, that are symbols used within an expression in order to specify the manipulations to be executed while evaluating that expression.

arithmetic: +, -, *, /, %

assignment: =

augmented assignment: +=, -=, *=, /=, %=, &=, |=, ^=, <<=, >>=

bitwise logic: ~, &, |, ^

bitwise shifts: <<, >>

boolean logic: !, &&, ||

conditional evaluation: ? :

equality testing: ==, !=

calling functions: ( )

increment and decrement: ++, --

member selection: ., ->

object size: sizeof

order relations: <, <=, >, >=

reference and dereference: &, *, [ ]

sequencing: ,

subexpression grouping: ( )

type conversion: (typename)

A Sample Code Of C

#include <stdio.h>
main()
{
printf("Hello World\n");
return 0;
}

C is the most commonly used programming language for writing operating systems. Unix was the first operating system written in C. Later Microsoft Windows, Mac OS X, and GNU/Linux were all written in C. Not only is C the language of operating systems, it is the precursor and inspiration for almost all of the most popular high-level languages available today. In fact, Perl, PHP, and Python are all written in C. As with all programming languages, whether you want to choose C over another high-level language is a matter of opinion and both technical and business requirements.