Thursday 5 December 2019

C Tutorial - Instruction set with Examples

C instruction set

Introduction

In previous section we discuss about various types of C constants, variables and keyword.

Now in this section we will discuss about how they are grouped to from instructions.

There are basically four types of instruction in C. which has been described separately.

1. Type Declaration Instruction

2. Input Output instruction

3. Arithmetic Instructions

4. Control Instructions

Type Declaration & Input/Output Instructions

This type of instruction is used to declare the type of variable being used in the program.

Any variable used in the program must be declared before using it in any statement.

This instruction is usually written at the beginning of the C program.

Example:

int a;
float re,ad;
char name ,des.

Input Output instructions

These instructions are used to supply input data to a program and obtain the output results from it.

Example:

printf(), scanf().


  
Arithmetic Instructions

These types of instructions are used to perform arithmetic operations between constants andvariables.

Some of the arithmetic operators are: +, -, * and /.

Example:

int a;
float b, deta, alpha, gamma, beta;
a=500;
b=0.0056;
deta=alpha*beta/gamma+0.5*2/5;

There are three types of arithmetic statements:

1. Integer mode arithmetic statement:

In this type of arithmetic statement all operands are either integer variable or integer constant.

2. Real mode arithmetic statement:

In this type of arithmetic statement all operands are either real constant or real variables.

3. Mixed mode arithmetic statement:

In this type of arithmetic statement some of the operands are integer and some of them are real.

Control Instructions

These types of instructions are used for controlling the sequence of execution of various statements in C program. It determines the 'flow of control' in a program.

There are four types of control instructions in C:

1. Sequence Control Instructions

The sequence control instruction ensures that the instructions are executed in the same order in which they appear in the program.

2. Selection or Decision Control Instructions

These types of instruction allow the computer to take a decision.

3. Case Control Instruction

These types of instruction determine which instruction is to be executed next.

4. Repetition or Loop Control Instruction

The loop control instruction helps computer to execute a group of statements repeatedly


Previous Page                                   Next Page

More Topics : 















100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...