Instructions in C Programming Language

Understand C Instructions:

Instructions in C are the commands in the program that will instruct C compiler to perform specific tasks or actions. Whenever we write a C instruction, we are telling C compiler to do a task for us.

For example, if I want to instruct C compiler to perform multiplication of 2 numbers, I can do that with help of C Arithmetic instruction. Similarly, if I want to declare a variable, I should be able to do that using Type declaration instruction in C. In this article, I will explain 3 different types of C instructions.

There are three types of instructions in C. They are as follows:

1) Type Declaration Instruction
2) Arithmetic Instruction
3) Control instruction

Type Declaration instruction in C

Type Declaration instruction is used to declare the type of variables to be used in a C program. Any variable that we want to use in the program must be declared before using it. This declaration is done using type declaration instruction.

Syntax: Type declaration instruction

data-type variable_name;

Here,
data-type represents any valid C data-type. E.g. int, char, float, double etc.
variable_name can be any valid name satisfying rules for constructing variables in C.

This declaration is done at the beginning of the main() function as shown below.

Example:

int main(){
     int balance, rate;
     float amount;
}

Arithmetic instructions in C

Arithmetic instructions are used to perform arithmetic operations on variables and constants.The variables and constants on which arithmetic operations are performed is called operands.

Following are the list of operators that can used to perform arithmetic operations in C

C Arithmetic Operators Description
+ addition or unary plus- used to perform addition
minus or unary minus – used to perform subtraction
* multiplication – used to perform multiplication
/ division – used to perform division
% modulo division – returns remainder after division

Example 1:

int main(){
     int a = 5, b = 10, c;
     c = a + b;
}

Here,
a, b and c are called operands
“=” and “+” are called C operators.
“=” is an assignment operator that is used to assign value of operand at R.H.S of “=” sign to variable at L.H.S.
“+” is an addition arithmetic operator that is used to perform addition operation on operands “a” and “b”.

Example 2:

int main(){
     int a;
     float b, c, d;
     a = 10;
     b = 0.05;
     c = 1.5;
     d = a +b * c;

Here,
“a” is integer variable.
“b”, “c” and “d” are real variables(float).
“=” is an assignment operator.
“+” and “*” are C arithmetic operators used to perform addition and multiplication arithmetic operation on the operands “a”, “b” and “c”.

Control instructions in C

Control instructions in C are used to control the sequence (flow) of the program execution.

We write a program to perform a particular task. The program might be addition of two numbers, subtraction of two number or division of two numbers. Let us suppose that we need to write a program to perform all the above three operations i.e. addition, subtraction and multiplication. Writing three different programs is not feasible. If we do so, then for addition, subtraction and division we need to run the program separately. Instead of doing this, we can include decision control statement. Using this we can decide within the program whether to perform addition, subtraction or division. Thus program becomes efficient and user friendly too.

Using decision control statement, we can perform different actions based on the circumstances.

Decision control instructions in C:

1) The if statement
2) The if-else statement
3) The conditional operators
4) The switch statement

You may also like...

26 Responses

  1. Anonymous says:

    “a is integer variable.
    b, c and d are real variables.”

    I get why a, b, c and d are all variables. I also understand why a is an integer. Why are b, c and d “real variables”? Wouldn’t they be floats?

    • Preeti tripathi says:

      Because integer are whole numbers they may positive negative or zero like 1,123,4325,_10 etc and 1.5,0.05 are not integer because they are decimal number and decimal number are not whole number

  2. Sam says:

    real is a synonym of float. Hence float can also be called as real variable.

  3. Anonymous says:

    Great site…

  4. LearnCOnline says:

    Thanks a lot. 🙂

  5. LearnCOnline says:

    If you like the post then please Tweet it/ Digg it or click on like (Facebook) button above. It would be hight appreciable.

  6. Anonymous says:

    I love this website. Thanks again. Became fan on facebook. Click adds every time I visit a page. Anything else I can do please let me know.

  7. LearnCOnline says:

    Nothing else… Just spread the name learnCOnline.com 🙂 Thank you

  8. Anonymous says:

    thanks for a lot.i’ve so many confusion before learning c. but it’s o.k for me now.

  9. Anonymous says:

    = is not a assignment variable, but its an assignment operator. right.

  10. LearnCOnline says:

    Thanks a lot for correcting us. Appreciate it.

  11. abhiav says:

    tnx man the site helped a lot

  12. prasanth says:

    a good site i was wondering since so many days for a site like this…

  13. Anonymous says:

    super……… blog……

  14. Ibrahim Dal says:

    Anyone tell me how to download c compiler program for Windows & Ultimate 64-bit ?
    Remember C program not C++

    • Jon Ross says:

      I love the content on this site. I have to reference back when I need to see linked lists again. For the users that need a download-able C compiler, I found Tenacious C to be great, and it has a graphical display that shows pointers actually pointing to pieces of memory.

  15. Anonymous says:

    can 2.0 be a float?

  16. Anonymous says:

    superb!!!!!!!!!!!!!!!!!!!!

  17. can i get a help in learning a c program

  18. hello can i get a easy instruction in learning a c program

  19. Itz_me says:

    Anything with a dot within before or after a number is a float (or) real variable I know this sounds stupid since 2.0 is nothing but 2 right but the computer will consider 2.0 as a float variable .

  20. paul nyarotso says:

    can i get all the notes on c programming.. please

  21. paul nyarotso says:

    great

  22. Kuldeep yadav says:

    Can I get notes of c programming please

Leave a Reply

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

FREE C Cheatsheet - Speed Up Your C Programming.

FREE C Cheatsheet - Speed Up Your C Programming.

Download a 7-page free cheat sheet for easy and quick access to C Concepts, Snippets, and Syntax.

Thank you! Check you inbox and access your cheat-sheet