Some Basics of C Language, You must Know

The C language was developed by Dennis M. Ritchie at the Bell Laboratories in the years 1969-1973. It was standardized by the ANSI (American National Standards Institute) committee into ANSI-C. The C language software from Borland Software Corporation is called Borland C or Turbo C. It’s a vastly advanced and rewritten version in C++ (pronounced as C plus-plus) which is one of the dominant languages today.

A Programming language is an artificial language for writing computer programs. Each language has its strictly defined set of keywords, data types, and syntax. Programming languages can be of two fundamental types, wiz, Low-level or Machine Language, and High-Level Language.

What is Machine language?

A Machine language is the only language that a computer recognizes directly. But it is difficult to write program instructions in a machine language. On the other hand, a high-level language is easier on the programmer. With its English words, basic mathematical symbols, and English-like structure.

What is High-Level language?

A High-level language is easier to learn and use. But a program written in a high-level language must be translated into machine language code before the computer can carry out those instructions. There are two types of translation programs:
An interpreter reads one line of your program translates and carries it out immediately before reading the next line of your program.

A compiler translates the entire program written in a high-level language into machine language codes and compiles them into a new “executable” file. C language is a relatively small language. C does not have built-in features to perform every function that we might ever need to do while programming. In a way, its small unambitious feature set is a real advantage: there’s less to learn. It can also be a disadvantage: since it doesn’t do everything for you, there’s a lot you have to do yourself. Programs written in C must be compiled before they can be executed.

Let us know some basics of C Language:
1) Keywords

Keywords are a small set of English words each of which has a special meaning for the C compiler to activate a specific routine or operation in the C language. Their meaning is already defined, and they cannot be re-defined to mean anything else. Some of the keywords in standard ANSI-C are:

auto       break       case       char      const    continue     do        double      else
extern    float         for         goto        if           int          long      main
return    short        signed    static    switch   unsigned    void       while


2) Data Types:

Data can be classified as character, numeric, date, logical, string, etc. Each of these is called a Data Type. There are only a few basic or primary data types in C Programming. Data types constructed from primary data types are called Secondary data types.

  • A computer stores a character by its ASCII numeric code.
  • A number that contains a decimal point is called a floating-point number.
  • The “e”, in the range column for types float and double, is a shorthand notation for multiplication by a power of 10; E.g., 3.4e – 38 = 3.4 x 10^-38
  • One byte is usually 8 bits.
3) Variables:

A variable a named area in memory that stores a value (numerical or string) assigned to that variable.  The value of a variable can be changed by the program when it is executed. A variable is denoted, and referred to, by its name. The type of a variable determines what kind of values it may take on. An operator computes new values out of old ones.

Within limits, you can give your variables (and functions) any names you want. These limitations are as follows:

  1. Every variable name must start with a letter or an underscore (letters are better). The rest of the name can consist of letters, numbers, and underscore characters. E.g., x1, _x1, result, outfile, out_file, hi_score.
  2. C recognizes upper and lower case characters as being different. Thus, variable names variable, Variable, VARIABLE, and variAble are all distinct. However, it is conventional to avoid the use of capital letters in variable names as its case sensitive.
  3. You cannot use any of C’s keywords (the words such as main, while, switch, etc which are part of the syntax of the language) as variable names.
4) Variable Declaration:

A declaration tells the compiler the name and type of a variable you will be using in your program. When you’re using a variable of some type, you have to remember what values it can take on and what operations you can perform on it. Therefore, when declaring a new variable and its type, you have to keep in mind the values and operations you will be needing it for.

In its simplest form, a declaration consists of the type, name of the variable, and a terminating semicolon. E.g.,
char c;
int i;
float f;

You can also declare several variables of the same type in one declaration, separating them with commas:
int i1, i2;

The placement of declarations is significant. You cannot place them just anywhere in a program. They must be placed at the beginning of the main or a user-defined function, immediately following the brace ({}). That is, variables must be declared before use. Then the compiler knows right away what amount of storage area will be required, and by what name that storage area will be accessed whenever the value of the variable has to be stored or recalled.

5) Constants:

A constant in a program is any data whose value will not be changed by the program. A numeric constant is any number. A constant that contains a decimal point, or the letter e (or both) is a floating-point constant. A sequence of keyboard characters forms a character string. A string constant is a character string enclosed in quotation marks, e.g., “Hello World”, “Morning”. Also, for example, 3.142 is a numeric constant whereas “3.142” is a string constant.

C Language allows you to declare constants, which is like variable declaration except that the value cannot be changed. The keyword const is used to declare a constant.

6) Operators and expressions:

An expression consists of variables, constants, and operators combined to perform some useful computation. Any ordinary algebraic expressions involving numeric constants and variables is called a Numeric expression. There are three types of Operators mainly: Arithmetic Operator, Assignment Operator, and Relational Operator.

a. Arithmetic Operators: Arithmetic Operations must be expressed explicitly using the arithmetic operators. This is how the basic arithmetic operations can be performed in C.

Operator Operation Syntax
+ Addition a + b
Subtraction a – b
* Multiplication a * b
/ Division a / b
% Modulus a % b

b. Assignment Operator: The assignment operator = assigned a value to a variable. For example, x = 1 sets x to 1 or a=b sets a to whatever b’s value is.

c. Relational Operators: These operators are used to make comparisons and control the flow of logic in a program using the if and switch statements. The complete set of relational operators in C is provided below:

Operator Syntax Meaning
> a > b or a > value If a is greater than b or if a is greater than any value specified.
>= a > = b or a > = value If a is greater than or equal to b or if a is greater than or equal to any value specified.
< a < b or a < value If a is less than b or if a is less than any value specified.
<= a < = b or a < = value If a is equal to b or if a is equal to the specified value.
== a = = b or a = = value If a is equal to b or if a is equal to the specified value.
!= a ! = b or a ! = value If a is not equal to b or if a is not equal to the specified value.

This what are the basics of the C Language. We hope you might learn something new if opting for C Language courses or any further studies. Do comment and share the article if it helped you in some way.


Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.