C (programming language)
- General-purpose, procedural language widely used for systems and application programming.
- Supports a wide range of data types, including primitive types and compound types like arrays and structures.
- Provides pointers for direct memory-address manipulation; commonly used in operating systems, computer hardware, and software development.
Definition
Section titled “Definition”C is a general-purpose, procedural computer programming language that was developed in the early 1970s by Dennis Ritchie.
Explanation
Section titled “Explanation”C is a high-level language that is easier to read and write than low-level languages closer to machine code. It supports a broad set of data types: primitive types such as integers and floating-point numbers, and more complex types such as arrays and structures. C also provides pointers—variables that store the memory address of another variable—enabling efficient manipulation of data and memory, which makes it suitable for low-level programming tasks.
The language includes standard headers (for example, stdio.h) that provide common functionality such as input and output. Every C program has a main function that serves as the program’s entry point.
Examples
Section titled “Examples”Average of three numbers
Section titled “Average of three numbers”#include <stdio.h>
int main()
{
int a = 3;
int b = 7;
int c = 9;
int sum = a + b + c;
int average = sum / 3;
printf("The average of %d, %d, and %d is %dn", a, b, c, average);
return 0;
}This program includes the “stdio.h” library for input and output functions such as printf. The main function is the program’s entry point. Inside main, three integer variables are declared and initialized with the values 3, 7, and 9. The program computes the sum of these numbers, divides the sum by 3 to obtain the average, and prints the result using printf with “%d” placeholders for integer values.
Output of the program:
The average of 3, 7, and 9 is 6
This example illustrates C’s support for various data types and its mechanisms for manipulating data and memory.
Use cases
Section titled “Use cases”- Operating systems
- Computer hardware
- Software development
Related terms
Section titled “Related terms”- Pointers
- Arrays
- Structures
- Primitive data types
- stdio.h
- main function
- printf