Basics of C Programming

What Is C?

C is a highly flexible and adaptable language. Since its creation in 1970, it’s been used for a wide variety of programs including firmware for micro-controllers, operating systems, applications, and graphics programming.

When was C developed?

C was developed at Bell Laboratories in 1972 by Dennis Ritchie along with Ken Thompson. Many of its principles and ideas were taken from the earlier language B and B’s earlier ancestors BCPL and CPL.

Who is the inventor of C?

Dennis Ritchie invented C, the computer-programming language that underlies Microsoft Windows, the Unix operating system and much of the other software running on computers around the world. Mr. Ritchie was a longtime research scientist at Bell Labs, originally AT&T’s research division.

Basics of a C Program

A C-program generally has the following parts:

  • Preprocessor Commands
  • Functions
  • Variables
  • Statements & Expressions
  • Comments

Let us consider a C Program:

#include<stdio.h>
void main()
{ 
  printf("Hello, World!");
}

Preprocessor Commands

These commands tell the compiler to do some preprocessing before executing the actual compilation. For example, “#include <stdio.h>” is a preprocessor command which tells a C compiler to include stdio.h file before going to actual compilation.

Functions

These are main building blocks of any C Program. Every C Program will at least have one function which is a mandatory function called main() function. This function is prefixed with keyword int or void or any other datatype. This defines the return type of the function. For int main() the program will return an integer value to the terminal (system).

The C Programming language provides a set of built-in functions. In the above example printf() is a C built-in function which is used to print anything on the screen.

Variables

These are used to hold numbers, strings and complex data for manipulation.

Statements & Expressions

Expressions combine variables and constants to create new values. Statements are expressions, assignments, function calls, or control flow statements which make up C programs.

Comments

Comments are used to give additional useful information inside a C Program. All the comments will be put inside /*…*/

Note

  • C is a case sensitive programming language. It means in C printf and Printf will have different meanings.
  • C has a free-form line structure. End of each C statement must be marked with a semicolon.
  • Multiple statements can be on the same line.
  • White Spaces (ie tab space and space bar ) are ignored.
  • Statements can continue over multiple lines.

 

Leave a Reply

Your email address will not be published. Required fields are marked *