How To Guides

Creating a Program in C Language

There are some rules for writing a program in C language and before writing the program you should have the knowledge of all the rules. Here are the rules you need to follow.

  • Each of the instruction in the C program is written in the separate statement. So we can say that a C program would be composed of a series of statements.
  • All the statement in the program should appear in the same order in which we want them to be executed unless the logic of the problem requires a jump or transfer of the control to a statement which is out of sequence.
  • You can insert blank spaces between two words to enhance the readability of the statement. However you can not add blank spaces within a variable, constant or keyword.
  • All of the statements needs to be entered in small case letters.
  • C language has got no specific rules for the position at which the statement needs to be written, therefore it is known as a free-form language.
  • Each C statement needs to be ended with a ; so ; acts as a statement eliminator.

Here is an example of C language program

/* Calculation of simple interest */

/* Author gekay Date: 5/10/2020 */

main( )


int p, n ;

float r, si ;

p = 1000 ;

n = 3 ;

r = 8.5 ;

/* formula for simple interest */

si = p * n * r / 100 ;

printf ( “%f” , si ) ;


Here are few tips about the above mentioned program

  • The comments about the program needs to be enclosed within /* */. like the first two statements in our program are comments.
  • Comments are not necessary but it is advisable to add comments in your program indicating the purpose of the program.
  • You can add any number of comments in the program and at any place like you can add comment before the statement, after the statement or within the statement.
  • In /* .. */ normal rules of the language do not apply therefore you can type the text in any case or combination.
  • A comment can be split over more than one line like

/* This is

a test

program */

How To Guides

Constants and Variables in C Language

Constants in C language

A constant is any entity that does not change it’s value. Constants have two types which are

  • Primary Constants (Integer Constant, Real Constant, Character Constant)
  • Secondary Constants (Array, Pointer, Structure, Union, Enum etc)

Integer Constants Construction Rules

  • An integar contant needs to have at least one digit.
  • It must not have a decimal point.
  • The Integer can be either positive or negative.
  • If there is no sign before an integer then it is a positive integer.
  • You can add commas or blanks within an integer constant.
  • The integer constants range is -32768 to 32768.

Real Constant Construction Rules:

Real Constants are also known as Floating Point constants. These constants can be written in two forms which are Fractional form as well as Exponential form.

Here are the rules that you need to observe while constructung real constants expressed in the fraction form.

  • Real constant must have a decimal point.
  • It must have minimum of one digit.
  • This constant can be positive or negative.
  • The default sign of Real integer is positive.
  • You can not add commas or blanks with a real constant.

Character Constant construction Rules:

  • A Character constant is a single alphabet, digit ot a special symbol that has been enclosed into a single inverted commas. Both of the inverted commas should point to the left.
  • Character constant’s maximum length can be one character.

C – Variables

A variable is an entity that may change during thr execution of the program. Variables names are the names given to the locations in the memory. The locations can contain integer, real or the character constants. The rules for constructing constants vary with the type of constant but the rules for constructing the variables in same.

Rules for Constructing Variable Names:

  • A variable name is any of the combination of 1 to 31 alphabets, numbers or underscores.
  • The character in the variable name must be an alphabet or underscore.
  • You can not add any commaor blank within the variable name.
  • You can not use any special symbol in a variable name other than an underscore.
How To Guides

Basics of C language


C is a programming language that has been developed by AT & T’s Bell Laboratories, USA in 1972. Dennis Ritchie was the man behind the designing and writing this language. C language gradually replaces it’s competitors like ALGOL, PL/I etc. C was never advertised but still programmers were preferring this language and it’s inventor was amazed at it. The reason behind the popularoty of C languages wwas its simplcity, ease of use and realiability. You may wonder that there are many languages that have surpassed C language like C++ and Java etc. but the fact is that for complete understanding of C++ and Java languages C language is a must.

Learning C Language

If you need to communicate with computer you need a language that computer understnads which means English is not the language of choice here. The first step of learning C language is to learn the alphabets, numbers and special symbols which are used in C. After this you need to know how to use constants, variables and keywords. All of these with a group of instructions form a program.

The C Character Set:

A character in C languages is any alphabet, number or special symbol used for representing information. The valid alphabets, numbers and special symbols are as follows

AlphabetsA, B, C, D, E, …….., X, Y, Z.
Special Symbols~ ‘ ! @ # % ^ & * ( ) _ – + = | \ { } [ ] : ; ” ‘ < > , . ? /

Constants, Variables and Keywords

The alphabets, numbers as well as special symbols mentioned above when combined in a proper way will form constants, variables and keywords.


A constant is an entity that does not change it’s value. There are two types of constants i.e. Primary Constants and Secondary Constants.


A variable is an entity that changes it’s value.


Keywords are actually the words whose meaning has been explained to the C compiler.