Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
44 views50 pages

C and DCF

Uploaded by

lata.yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views50 pages

C and DCF

Uploaded by

lata.yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 50

Programming using C and Digital Computer

Fundamentals (CSC131)
CSC- 131N
(Week 2)
Ms. Garima Anand

MISSION VISION CORE VALUES


CHRIST is a nurturing ground for an individual’s holistic Excellence and Service Faith in God | Moral Uprightness
development to make effective contribution to the society in a Love of Fellow Beings 1
dynamic environment Social Responsibility | Pursuit of Excellence
CHRIST
Deemed to be University

Algorithm
Example 1: Algorithm to add 2 numbers and print their Algorithm to add 2 numbers and print their sum:
sum:
Step 1: Start
Step 1: START
Step 2: Declare variables num1, num2 and sum.
Step 2: Declare 2 integer variables num1 and num2.
Step 3: Read values num1 and num2.
Step 3: Take the 2 numbers, to be added, as inputs in
Step 4: Add num1 and num2 and assign the
variables num1, num2, respectively.
result to sum. sum←num1+num2
Step 4: Declare an integer variable sum to store the resultant
Step 5: Display sum
sum of the 2 numbers.
Step 6: Stop
Step 5: Add the 2 numbers and store the result in the
variable sum.
Step 6: Print the value of variable sum
Step 7: END 2
Excellence and Service
CHRIST
Deemed to be University

Use of Mathematical and Relation Operator

Operator Meaning Example


+ Addition A+ B
- Subtraction A–B
* Multiplication A* B
/ Division A/ B
^ Power A^3
% Reminder A%B
= Equal to A= B
< Less than A< B
> Greater than A> B

3
Excellence and Service
CHRIST
Deemed to be University

Use of Selection Control

Operator Meaning Example


IF (Condition) Then If condition X>10 is True execute the IF ( X > 10 )
… statement between THEN and ENDIF THEN
ENDIF Y=Y+5
ENDIF
IF ( Condition ) If condition X>10 is True execute the IF ( X > 10 )
Then statement between THEN and ELSE THEN
… otherwise execute the statements between Y=Y+5
ELSE ELSE and ENDIF ELSE Y=Y+8
….. Z=Z+3
ENDIF ENDIF

4
Excellence and Service
CHRIST
Deemed to be University

Algorithm
Example 1: Algorithm to find the discriminant of a quadratic equation:
Step 1: START
Step 2: Read the coefficients of the quadratic equation, a, b and c from the user.
Step 3: Calculate discriminant = (b * b) – (4 * a * c).
Step 4: Display the discriminant.
Step 5: END

5
Excellence and Service
CHRIST
Deemed to be University

Algorithm

Example 2: Algorithm to find the roots of a quadratic


equation:
Else:
Step 1: START
Calculate real = -b / (2 * a)
Step 2: Read the coefficients of the equation, a, b and c from the user.
Calculate imaginary = sqrt(-discriminant) / (2 * a)
Step 3. Calculate discriminant = (b * b) – (4 * a * c)
Display “Roots are imaginary”
Step 4. If discriminant > 0:
Display real, “±” , imaginary, “i”
Calculate root1 = ( -b + sqrt(discriminant)) / (2 * a)
Step 5. Display root1 and root2
Calculate root2 = ( -b - sqrt(discriminant)) / (2 * a)
Step 6: END
Display “Roots are real and different”
Else if discriminant = 0:
Calculate root1 = -b / (2 *a)
root2 = root1
Display “Root are real and equal” 6
Excellence and Service
CHRIST
Deemed to be University

Algorithm
Example 3: Algorithm to find sum of digits of a number:
Step 1: START
Step 2: Input N
Step 3: Sum = 0
Step 4: While (N != 0)
Rem = N % 10;
Sum = Sum + Rem;
N = N / 10;
Step 5: Print Sum
Step 6: END

7
Excellence and Service
CHRIST
Deemed to be University

Algorithm
Example 4: Algorithm to check whether a number is a palindrome:
Step 1: START
Step 2: Take a number n as input
Step 3: Copy value of n to another variable say m i.e. m = n.
Step 4: Initialize reverse = 0.
Step 5: Perform r = n% 10.
Step 6: Perform reverse = reverse * 10 + r.
Step 7: Perform n = n /10.
Step 8: If n = 0 go to step 9 else go to step 5.
Step 9: Check if reverse == m.
Step 10: If step 8 is true then n is palindrome else n is not a palindrome.
Step 11: END
8
Excellence and Service
CHRIST
Deemed to be University

Algorithm :
1. To find the number of odd numbers in a given list of N numbers.
2. To find the largest and smallest of any given N numbers.

9
Excellence and Service
CHRIST
Deemed to be University

Flowcharts

10
Excellence and Service
CHRIST
Deemed to be University
Flowchart

A flowchart can be defined as a diagrammatic representation of


an algorithm, a step-by-step approach to solving a task.

Prepare a tea
Step 1: START
Step 2: Pour 2 cup of water in frying pan and put it on stove
Step 3: Add 2 spoon tea and 2 spoon sugar
Step 4: Add 2 cup milk
Step 5: Wait for water to boil
Step 6: Put tea in a cup
Step 7 :END

11
Excellence and Service
CHRIST
Deemed to be University
Flowchart

Benefits of Flow Chart:


● One of the key benefits is the ability to imagine multiple steps in a single sequence
● Effective Analysis.
● Problem Solving.
● Proper Documentation.
● Flowcharts are better way of communicating the logic of a system to all concerned or involved.

12
Excellence and Service
CHRIST
Deemed to be University
Flowchart

Symbols used in a flowchart:


• Start / Stop
• Process
• Input / Output
• Decision
• Arrow
• On-Page Connector
• Off-Page Connector

13
Excellence and Service
CHRIST
Deemed to be University
Flowchart
Example 1 : Find To check whether a given number is odd or even.
●Algorithm
Step 1: Start
Step 2: READ number
Step 3: remainder=number%2
Step 4: IF remainder = = 0
Print "Even Number"
ELSE
Print "Odd Number"
ENDIF
Step 5: End

14
Excellence and Service
CHRIST
Deemed to be University
Flowchart
Example 2 : Find Area and Perimeter of a Square Start
●Algorithm
Step 1: Start Input Value of Len
Step 2: Input Side Length of Square say Len
Step 3: Area = Len x Len Area = Len X Len
Step 4: PERIMETER = 4 x Len
Step 5: Display AREA, PERIMETER
Perimeter = 4 X Len
Step 6: Stop

Print Area &


Perimeter

Stop

15
Excellence and Service
CHRIST
Deemed to be University
Flowchart
Example 3 : Find Largest of three numbers Start

Algorithm
Input A, B and C
Step 1: Start
Step 2: Read three numbers say A,B,C
Large = A
Step 3: Large = A
Step 4: IF B > Large THEN Is B > Yes Large = B
Large
Large = B
No
ENDIF
Is C > Yes Large = C
Step 5: IF C >Large THEN Large

Large = C No
ENDIF Write Large

Step 6: Write Large


Stop
Step 7: Stop
Excellence and Service
CHRIST
Deemed to be University

Flowchart :
1. To print multiplication table of a given number.
2. To print Fibonacci series from 0 to N.
3. To find sum of two numbers.
4. To find sum of digits of a number.
5. To find factorial of last digit of a number.
6. To accept three sides of a triangle and check whether it is an equilateral triangle.
7. To check whether a given number is positive.
8. To find sum of first N natural numbers.
9. To find the number of negative numbers in a given list of N numbers.

17
Excellence and Service
CHRIST
Deemed to be University

Introduction to C

18
Excellence and Service
CHRIST
Deemed to be University
Introduction

● C is a programming language developed at AT & T’s Bell Laboratories of USA in 1972.


● It was designed and written by Dennis Ritchie.
● C seems so popular is because it is reliable, simple and easy to use.
● Major parts of popular operating systems like Windows, UNIX, Linux and Android are
written in C.
● Many popular gaming frameworks (like DirectX) have been built using C language.

19
Excellence and Service
CHRIST
Deemed to be University
Introduction

● There is a close analogy between learning English language and learning C language.

● Instead of straight-away learning how to write programs, we must first know what alphabets,
numbers and special symbols are used in C, then how using them, constants, variables and keywords
are constructed, and finally, how are these combined to form an instruction.
● A group of instructions would be combined later on to form a program.
20
Excellence and Service
CHRIST
Deemed to be University
C Character Set

● A character denotes any alphabet, digit or special symbol used to represent information.
● Figure shows the valid alphabets, numbers and special symbols allowed in C.

21
Excellence and Service
CHRIST
Deemed to be University
Constants, Variables and Keywords

● The alphabets, digits and special symbols when properly combined form constants, variables and keywords.
● A constant is an entity that doesn’t change.
● A variable is an entity that may change.
● A keyword is a word that carries special meaning.
● In any C program we typically do lots of calculations. The results of these calculations are stored in computer’s
memory. To make the retrieval and usage of these values easy, memory locations are given names.
● Since the value stored in each location may change, the names given to these locations are called variable names.

22
Excellence and Service
CHRIST
Deemed to be University

Constants, Variables and Keywords

● Since the location whose name is x can hold different values at different times x is known as a
variable (or a variable name).
● As against this, 3 or 5 do not change, hence are known as constants.
● In programming languages, constants are often called literals, whereas, variables are called
identifiers.

23
Excellence and Service
CHRIST
Deemed to be University

Types of C Constants

● C constants can be divided into two major categories:


(a) Primary Constants
(b) Secondary Constants

24
Excellence and Service
CHRIST
Deemed to be University

Types of C Constants

● Rules for Constructing Integer Constants


(a) An integer constant must have at least one digit.
(b) It must not have a decimal point.
(c) It can be either positive or negative.
(d) If no sign precedes an integer constant, it is assumed to be positive.
(e) No commas or blanks are allowed within an integer constant.
(f) The allowable range for integer constants is -2147483648 to +2147483647.
For example: 426
+782
-8000
-7605
25
Excellence and Service
CHRIST
Deemed to be University
Types of C Constants

● Real constants are often called Floating Point constants.


● The real constants could be written in two forms—Fractional form and Exponential form.
● Following rules must be observed while constructing real constants expressed in fractional form:
(a) A real constant must have at least one digit.
(b) It must have a decimal point.
(c) It could be either positive or negative.
(d) Default sign is positive.
(e) No commas or blanks are allowed within a real constant.

For example: +325.34


426.0
-32.76
-48.5792
26
Excellence and Service
CHRIST
Deemed to be University
Types of C Constants

● The exponential form is usually used if the value of the constant is either too small or too large.
● In exponential form the real constant is represented in two parts. The part appearing before ‘e’ is
called mantissa, whereas the part following ‘e’ is called exponent. Thus 0.000342 can be written in
exponential form as 3.42e-4 (which in normal arithmetic means 3.42 x 10 -4).
● Following rules must be observed while constructing real constants expressed in exponential form:
(a) The mantissa part and the exponential part should be separated by a letter e or E.
(b) The mantissa part may have a positive or negative sign.
(c) Default sign of mantissa part is positive.
(d) The exponent must have at least one digit, which must be a positive or negative integer. Default
sign is positive.
(e) Range of real constants expressed in exponential form is -3.4e38 to 3.4e38.
27
Excellence and Service
CHRIST
Deemed to be University

Types of C Constants

● Rules for Constructing Character Constants


(a) A character constant is a single alphabet, a single digit or a single special symbol enclosed within
single inverted commas.
(b) Both the inverted commas should point to the left. For example, ’A’ is a valid character constant
whereas ‘A’ is not.
For Example: 'A'
'I'
'5'
'='

28
Excellence and Service
CHRIST
Deemed to be University

Types of C Variables

● A particular type of variable can hold only the same type of constant.
● For example, an integer variable can hold only an integer constant, a real variable can hold only a real
constant and a character variable can hold only a character constant.
● The rules for constructing different types of constants are different.
● However, for constructing variable names of all types, the same set of rules applies.
● Rules for Constructing Variable Names:
(a) A variable name is any combination of 1 to 31 alphabets, digits or underscores. Some compilers
allow variable names whose length could be up to 247 characters. Still, it would be safer to stick
to the rule of 31 characters. Do not create unnecessarily long variable names as it adds to your
typing effort.

29
Excellence and Service
CHRIST
Deemed to be University

Types of C Variables

b) The first character in the variable name must be an alphabet or underscore ( _ ).


c) No commas or blanks are allowed within a variable name.
d) No special symbol other than an underscore (as in gross_sal) can be used in a variable name.

For Example: si_int


m_hra
pop_e_89

● It is always advisable to construct meaningful variable names like prin, roi, noy to represent
Principle, Rate of interest and Number of years rather than using the variables a, b, c

30
Excellence and Service
CHRIST
Deemed to be University

Types of C Variables

● C compiler is able to distinguish between the variable names by making it compulsory for you to
declare the type of any variable name that you wish to use in a program.
● This type declaration is done at the beginning of the program.

For Example: int si, m_hra ;


float bassal ;
char code ;

31
Excellence and Service
CHRIST
Deemed to be University

C Keywords

● Keywords are the words whose meaning has already been explained to the C compiler (or in a broad
sense to the computer).
● There are only 32 keywords available in C.

● keywords cannot be used as variable names because if we do so, we are trying to assign a new
meaning to the keyword, which is not allowed.

32
Excellence and Service
CHRIST
Deemed to be University
The First C Program
/* Calculation of simple interest */
# include <stdio.h>

int 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\n" , si ) ;
return 0 ;
}
33
Excellence and Service
CHRIST
Deemed to be University
The First C Program

There are certain rules about the form of a C program that are applicable to all C programs. These are as
under:
(a) Each instruction in a C program is written as a separate statement.
(b) The statements in a program must appear in the same order in which we wish them to be executed.
(c) Blank spaces may be inserted between two words to improve the readability of the statement.
(d) All statements should be in lower case letters.
(e) C has no specific rules for the position at which a statement is to be written in a given line. That’s
why it is often called a free-form language.
(f) Every C statement must end with a semicolon ( ; ). Thus ; acts as a statement terminator.

34
Excellence and Service
CHRIST
Deemed to be University
The First C Program

Comments in a C program: /* Calculation of simple interest */


# include <stdio.h>
● Comments are used in a C program to clarify either the
int main( )
purpose of the program or the purpose of some statement in the {
program. int p, n ;
float r, si ;
● It is a good practice to begin a program with a comment
p = 1000 ;
indicating the purpose of the program, its author and the date n=3;
on which the program was written. r = 8.5 ;

● Here are a few things that you must remember while writing /* formula for simple interest */
si = p * n * r / 100 ;
comments in a C program:
(a) Comment about the program should be enclosed within /* */. printf ( "%f\n" , si ) ;
return 0 ;
Thus, the first statement in our program are comments. }
35
Excellence and Service
CHRIST
Deemed to be University
The First C Program

Comments in a C program: /* Calculation of simple interest */


# include <stdio.h>
b) Sometimes it is not very obvious as to what a particular
int main( )
statement in a program accomplishes. At such times it is {
worthwhile mentioning the purpose of the statement (or a set int p, n ;
float r, si ;
of statements) using a comment.
p = 1000 ;
For example: n=3;
/* formula for simple interest */ r = 8.5 ;

si = p * n * r / 100 ; /* formula for simple interest */


si = p * n * r / 100 ;
(c) Any number of comments can be written at any place in the
program. For example, a comment can be written before the printf ( "%f\n" , si ) ;
return 0 ;
statement, after the statement or within the statement . }
36
Excellence and Service
CHRIST
Deemed to be University
The First C Program
Comments in a C program:
(d) The normal language rules do not apply to text written within /* .. */. Thus we can type this text in small case,
capital or a combination. This is because the comments are solely given for the understanding of the programmer
or the fellow programmers and are completely ignored by the compiler.
(e) Comments cannot be nested. This means one comment cannot be written inside another comment. For example, /*
Cal of SI /* Author: gekay date: 25/06/2016 */ */ is invalid.
(f) A comment can be split over more than one line, as in,
/* This comment has
three lines
in it */
Such a comment is often called a multi-line comment.
(g) ANSI C permits comments to be written in the following way:
// Calculation of simple interest Formula
37
Excellence and Service
CHRIST
Deemed to be University
The First C Program
Main ( ) :
● main( ) is a function.
● A function is nothing but a container for a set of statements.
● In a C program there can be multiple functions.
● To begin with, we would concentrate only on those programs which have only one function. The
name of this function has to be main( ), it cannot be anything else.
● All statements that belong to main( ) are enclosed within a pair of braces { } as shown below.
int main( )
{
statement 1 ;
statement 2 ;
statement 3 ;
}
38
Excellence and Service
CHRIST
Deemed to be University
The First C Program

Main ( ) : /* Calculation of simple interest */


# include <stdio.h>
● The way functions in a calculator return a value, similarly, functions
in C also return a value. int main( )
{
● main( ) function always returns an integer value, hence there is an int
int p, n ;
before main( ). float r, si ;
● The integer value that we are returning is 0. 0 indicates success.
p = 1000 ;
● If for any reason the statements in main( ) fail to do their intended n=3;
r = 8.5 ;
work we can return a non-zero number from main( ). This would
indicate failure. /* formula for simple interest */
si = p * n * r / 100 ;
● Some compilers like Turbo C/C++ even permit us to return nothing
from main( ). In such a case we should precede it with the keyword printf ( "%f\n" , si ) ;
return 0 ;
void. But this is non-standard way of writing the main( ) function.
}
39
Excellence and Service
CHRIST
Deemed to be University
The First C Program

Variables and their Usage:


● Any variable used in the program must be declared before using it.
For example,
int p, n ; /* declaration */
float r, si ; /* declaration */
si = p * n * r / 100 ; /* usage */

● In the statement,
si = p * n * r / 100 ;
and / are the arithmetic operators. The arithmetic operators available in C are +, -, * and /.
● C is very rich in operators. There are as many as 45 operators available in C. Surprisingly there is no
operator for exponentiation.
40
Excellence and Service
CHRIST
Deemed to be University
The First C Program

printf( ) and its Purpose : /* Calculation of simple interest */


# include <stdio.h>
● C does not contain any instruction to display output on the screen.

● All output to screen is achieved using readymade library functions. int main( )
{
One such function is printf( ). int p, n ;
float r, si ;
● Let us understand this function with respect to our program.

(a) Once the value of si is calculated it needs to be displayed on the p = 1000 ;


n=3;
screen. We have used printf( ) to do so. r = 8.5 ;

(b) For us to be able to use the printf( ) function, it is necessary to use /* formula for simple interest */
#include <stdio.h> at the beginning of the program. si = p * n * r / 100 ;

#include is a preprocessor directive. For now, use it whenever printf ( "%f\n" , si ) ;


return 0 ;
you use printf( ).
}
41
Excellence and Service
CHRIST
Deemed to be University
The First C Program

printf( ) and its Purpose : /* Calculation of simple interest */


# include <stdio.h>
● The general form of printf( ) function is,

printf ( "<format string>", <list of variables> ) ; int main( )


{
<format string> can contain, int p, n ;
float r, si ;
%f for printing real values
p = 1000 ;
%d for printing integer values n=3;
r = 8.5 ;
%c for printing character values

● In addition to format specifiers like %f, %d and %c, the format string /* formula for simple interest */
si = p * n * r / 100 ;
may also contain any other characters. These characters are printed as
they are when printf( ) is executed. printf ( "%f\n" , si ) ;
return 0 ;
}
42
Excellence and Service
CHRIST
Deemed to be University
The First C Program
printf( ) and its Purpose :
/* Calculation of simple interest */
● Given below are some more examples of usage of printf( ) function: # include <stdio.h>
printf ( "%f", si ) ;
int main( )
printf ( "%d %d %f %f", p, n, r, si ) ; {
int p, n ;
printf ( "Simple interest = Rs. %f", si ) ; float r, si ;
printf ( "Principal = %d \nRate = %f", p, r );
p = 1000 ;
● printf( ) can not only print values of variables, it can also print the result of n=3;
r = 8.5 ;
an expression. An expression is nothing but a valid combination of
constants, variables and operators. /* formula for simple interest */
si = p * n * r / 100 ;
printf ( "%d %d %d %d", 3, 3 + 2, c, a + b * c – d ) ;

● \n - It is called newline and it takes the cursor to the next line. Therefore, printf ( "%f\n" , si ) ;
return 0 ;
you get the output split over two lines. }
43
Excellence and Service
CHRIST
Deemed to be University
The First C Program
Receiving Input:
/* Calculation of simple interest */
● In the program discussed in previous slides we assumed the values of
p, n and r to be 1000, 3 and 8.5. Every time we run the program we # include <stdio.h>
int main( )
would get the same value for simple interest. {
int p, n ;
● To make the program general, the program itself should ask the user to float r, si ;
supply the values of p, n and r through the keyboard during
printf ( "Enter values of p, n, r" ) ;
execution. scanf ( "%d %d %f", &p, &n, &r ) ;
● This can be achieved using a function called scanf( ). This function is
si = p * n * r / 100 ;
a counter-part of the printf( ) function.
printf ( "%f\n" , si ) ;
● printf( ) outputs the values to the screen whereas scanf( ) receives return 0 ;
them from the keyboard. }

44
Excellence and Service
CHRIST
Deemed to be University
The First C Program
Receiving Input:
● The first printf( ) outputs the message ‘Enter values of p, n, r’ on the /* Calculation of simple interest */

screen. Here we have not used any expression in printf( ) which means # include <stdio.h>
that using expressions in printf( ) is optional. int main( )
{
● The use of ampersand (&) before the variables in the scanf( ) function is int p, n ;
a must. float r, si ;

● & is an ‘Address of’ operator. It gives the location number (address) printf ( "Enter values of p, n, r" ) ;
used by the variable in memory. scanf ( "%d %d %f", &p, &n, &r ) ;

● When we say &a, we are telling scanf( ) at which memory location should si = p * n * r / 100 ;
it store the value supplied by the user from the keyboard.
printf ( "%f\n" , si ) ;
● A blank, a tab or a new line must separate the values supplied to scanf( ). return 0 ;
}
A blank is created using a spacebar, tab using the Tab key and new line
using the Enter key.
45
Excellence and Service
CHRIST
Deemed to be University
C Instructions

● A program is nothing but a set of instructions.

● The program behaves as per the instructions that we give in it.

● Different instructions help us achieve different tasks in a program.

● There are basically three types of instructions in C:

(a) Type Declaration Instruction – This instruction is used to declare the type of variables used in a C program.

(b) Arithmetic Instruction – This instruction is used to perform arithmetic operations on constants and variables.

(c) Control Instruction – This instruction is used to control the sequence of execution of various statements in a C

program.

46
Excellence and Service
CHRIST
Deemed to be University
Type Declaration Instruction

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

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

● The type declaration statement is written at the beginning of main( ) function.

● For example: int bas ;

float rs, grosssal ;

char name, code ;

47
Excellence and Service
CHRIST
Deemed to be University
Type Declaration Instruction
● There are several subtle variations of the type declaration instruction.
(i) While declaring the type of variable we can also initialize it as :
int i = 10, j = 25 ;
float a = 1.5, b = 1.99 + 2.4 * 1.44 ;
(ii) The order in which we define the variables is sometimes important sometimes not. For example,
int i = 10, j = 25 ;
is same as
int j = 25, i = 10 ;
However,
float a = 1.5, b = a + 3.1 ; is alright,
but
float b = a + 3.1, a = 1.5 ; is not.
This is because here we are trying to use a before defining it.
48
Excellence and Service
CHRIST
Deemed to be University
Type Declaration Instruction
(iii) The following statements would work
int a, b, c, d ;
a = b = c = 10 ;
However, the following statement would not work
int a = b = c = d = 10 ;
Once again we are trying to use b (to assign to a) before defining it.

49
Excellence and Service
CHRIST
Deemed to be University
Arithmetic Instructions

● A C arithmetic instruction consists of a variable name on the left hand side of = and variable names and constants
on the right hand side of =.
● The variables and constants appearing on the right hand side of = are connected by arithmetic operators like +, -, *,
and /.
● For example : int ad ;
Here, *, /, -, + are the arithmetic operators.
float kot, deta, alpha, beta, gamma ; = is the assignment operator.
ad = 3200 ; 2, 5 and 3200 are integer constants.
kot = 0.0056 ; .2 and 0.0056 are real constants. ad is an integer variable.

deta = alpha * beta / gamma + 3.2 * 2 / 5; kot, deta, alpha, beta, gamma are real variables

● The variables and constants together are called ‘operands’. While executing an arithmetic statement the operands
on right hand side are operated upon by the ‘arithmetic operators’ and the result is then assigned, using the
assignment operator, to the variable on left-hand side.
50
Excellence and Service

You might also like