ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

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.

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
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:

  1. _Bool
  2. _Complex
  3. _Imaginary
  4. inline
  5. restrict


C11 adds seven more keywords:

  1. _Alignas
  2. _Alignof
  3. _Atomic
  4. _Generic
  5. _Noreturn
  6. _Static_assert
  7. _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):

  1. auto
  2. break
  3. case
  4. char
  5. const
  6. continue
  7. default
  8. do
  9. double
  10. else
  11. enum
  12. extern
  13. float
  14. for
  15. goto
  16. if
  17. int
  18. long
  19. register
  20. return
  21. short
  22. signed
  23. sizeof
  24. static
  25. struct
  26. switch
  27. typedef
  28. union
  29. unsigned
  30. void
  31. volatile
  32. 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.

  • <assert.h>
  • <complex.h>
  • <ctype.h>
  • <errno.h>
  • <fenv.h>
  • <float.h>
  • <inttypes.h>
  • <iso646.h>
  • <limits.h>
  • <locale.h>
  • <math.h>
  • <setjmp.h>
  • <signal.h>
  • <stdarg.h>
  • <stdatomic.h>
  • <stdbool.h>
  • <stddef.h>
  • <stdint.h>
  • <stdio.h>
  • <stdlib.h>
  • <stdnoreturn.h>
  • <string.h>
  • <tgmath.h>
  • <threads.h>
  • <time.h>
  • <uchar.h>
  • <wchar.h>
  • <wctype.h>

Character Set

The basic C source character set includes the following characters:

  • Letters: a–z, A–Z, _
  • Digits: 0–9
  • Punctuation: ~ ! @ # % ^ & * ( ) - + = : ; " ' < > , . ? | / \ { } [ ]
  • Whitespace characters: space, horizontal tab, vertical tab, form feed, newline

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.



working

This website uses cookies

As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://corp.maven.io/privacy-policy

Show Details
Necessary
HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
LoginThis is necessary to sign in to the HubPages Service.
Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
AkismetThis is used to detect comment spam. (Privacy Policy)
HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
Features
Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
MavenThis supports the Maven widget and search functionality. (Privacy Policy)
Marketing
Google AdSenseThis is an ad network. (Privacy Policy)
Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
Index ExchangeThis is an ad network. (Privacy Policy)
SovrnThis is an ad network. (Privacy Policy)
Facebook AdsThis is an ad network. (Privacy Policy)
Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
AppNexusThis is an ad network. (Privacy Policy)
OpenxThis is an ad network. (Privacy Policy)
Rubicon ProjectThis is an ad network. (Privacy Policy)
TripleLiftThis is an ad network. (Privacy Policy)
Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
Statistics
Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)
ClickscoThis is a data management platform studying reader behavior (Privacy Policy)