Skip to main content icon/video/no-internet

C Programming Languages

The family of C programming languages, consisting of C, C++, C#, and Objective-C, is a set of similar languages from different paradigms. The first of these languages, C, serves as the foundation for the set because its syntax, structure, and logic strongly influenced the development of the latter languages. Perhaps the most notable difference is that C# and Objective-C are object-oriented languages using classes that gain additional programming properties to build on the C language. The C++ language is inherently capable of object-oriented programming, but its flexibility also allows it to be programmed in the same paradigm as C. Due to the large number of similarities between them, a deeper understanding of C facilitates learning the other languages, as its programming principles can be generalized to the others. For that reason, this entry focuses on C, providing programming principles, sample code, compilation, and applications to educational research, measurement, and evaluation.

Programming Principles in C

Programming languages follow paradigms or ways of writing code at different levels of abstraction (i.e., how closely the language resembles the binary machine code of 0s and 1s). C follows an imperative (and more specifically, procedural) paradigm, which means that the code describes how to perform a task.

C code accomplishes tasks using functions, a term that bears similarity to the mathematical definition. Functions use input to produce output, although this is not always the case. Some functions perform tasks with no explicit input values required, and others use input to perform a task with no specific output values. The main function is a requirement in C code when it is compiled to produce an executable program.

A collection of functions written in a single file to be used across multiple programs is called a library (which may have a static library file extension, *.a or *.lib, or dynamic library file extension, *.so or *.dll). A library may contain header files (with the file extension *.h), which are preprocessing directives that are evaluated before source code (i.e., the program that a user writes). A primary example of this is the C Standard Library, and it contains a standardized set of header files that allows for basic commonly used functions to be used by programs. More specifically, a header file (e.g., <stdio.h>) contains the standard input/output functions that are not reserved words in the C language. Under the current C11 standard, there are 44 reserved words in C that cannot be used for naming variables or functions; for instance, a variable cannot be named int because the compiler understands that term to denote the integer data type. If the end goal is a user-written library, an executable program is not required because libraries typically do not have an execution thread of their own.

There are four basic data types that can be specified in C. First, arithmetic data types are used to store alphanumeric symbols in memory (i.e., char, int, float, and double). Second, type modifiers can be used to denote the possibility of negative values (i.e., signed vs. unsigned) or the amount of memory needed (e.g., the number of decimal places) for that particular value (i.e., short vs. long). Third, enumerated data types are useful for situations involving loops and discrete calculations, such as dummy codes and categorical indicators. Finally, void data types are null values that serve as a proxy for functions returning no values or for declaring pointers to variable locations in memory without specifying a particular data type. However, the classification of these data types could be conceptualized in multiple fashions. It is even possible to declare constants, as opposed to variables, for those values in memory that should not be changed during code execution. Declaring variables is technically separate from initialization. The former creates and names the variable, while the latter gives the variable a starting value.

...

  • Loading...
locked icon

Sign in to access this content

Get a 30 day FREE TRIAL

  • Watch videos from a variety of sources bringing classroom topics to life
  • Read modern, diverse business cases
  • Explore hundreds of books and reference titles

Sage Recommends

We found other relevant content for you on other Sage platforms.

Loading