# COMPUTER CLASS ASSESSMENT

Published on
##### Scene 1 (0s)

COMPUTER CLASS ASSESSMENT

##### Scene 2 (4s)

TOPIC

ALGORITHM & VARIABLES

##### Scene 3 (14s)

OVERVIEW

Breif discripton of Algorithms and Variables In C language

01

##### Scene 4 (23s)

ALGORITHMS

Introduction

Al gorithm refers to a set of rules/instructions that in a step-by-step manner defines how a work is to be executed upon in order to get the expected results.

##### Scene 5 (39s)

BASIC FLOW CHART OF AN ALGORITHM.

'nd1nO -"iriti70elA Iqaæoblv babadx.-• auneiqöoi X salm S! leqM

##### Scene 6 (53s)

Characteristics of an Algorithm well-Defined • Inputs • Clear and Unambiguous Language Independent Well-Defined • Outputs Characteristics of Finite-ness an Algorithm Feasible

##### Scene 7 (1m 16s)

WHAT MAKES AN ALGORITHM PURPOSEFUL?

Clear and Unambiguous : Each of its steps should be clear in all aspects and must lead to only one meaning. Well-Defined Inputs : If an algorithm says to take inputs, it should be well-defined inputs. Well-Defined Outputs :  The algorithm must clearly define what output will be yielded and it should be well-defined as well. Finite-ness :  The algorithm must be finite, i.e. it should not end up in an infinite loops or similar. Feasible :  The algorithm must be simple, generic and practical, such that it can be executed upon wi th the available resources. It must not contain some future technology, or anything. Language Independent :  The Algorithm designed must be language-independent, i.e. it must be just plain instructions that can be implemented in any language, and yet the output will be same, as expected.

##### Scene 8 (2m 6s)

It is easy to understand.

Algorithm is a step-wise representation of a solution to a given problem.

In Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.

##### Scene 9 (2m 30s)

Writing an algorithm takes a long time so it is time-consuming

Branching and Looping statements are difficult to show in Algorithms

hmm.

##### Scene 10 (2m 56s)

IMPORTANT NOTES

We design an algorithm to get a solution of a given problem. A problem can be solved in more than one ways. Hence, many solution algorithms can be derived for a given problem. The next step is to analyze those proposed solution algorithms and implement the best suitable solution.

##### Scene 11 (3m 16s)

HOW TO DESIGN AN ALGORITHM ?

##### Scene 12 (3m 29s)

In order to write an algorithm, following things are needed as a pre-requisite:   The  problem  that is to be solved by this algorithm. The  constraints  of the problem that must be considered while solving the problem. The  input  to be taken to solve the problem. The  output  to be expected when the problem the is solved. The  solution  to this problem, in the given constraints.

##### Scene 13 (3m 57s)

PROGRAM (INPUT)

#include < stdio.h > #include < conio.h > sum(10,20,30); void main() sum( int x,int y,int z)

##### Scene 14 (4m 31s)

DOS30x 0.74, Cpu speed: cycles, Frameskip a, Program: CCEPT I.RLUE FOR UM OF and 30 IS CCEbl IWI" I-IE LOB g • p 'c: cbn 2bGGq:

PROGRAM (OUTPUT)

##### Scene 15 (4m 52s)

ALGORITHM ANALYSIS

Priori  Analysis  − This is a theoretical analysis of an algorithm. Efficiency of an algorithm is measured by assuming that all other factors, for example, processor speed, are constant and have no effect on the implementation.

Posteriori  Analysis   − This is an empirical analysis of an algorithm. The selected algorithm is implemented using programming language. This is then executed on target computer machine. In this analysis, actual statistics like running time and space required, are collected.

##### Scene 16 (5m 21s)

ALGORITHM COMPLEXITY

. Time Factor   − Time is measured by counting the number of key operations such as comparisons in the sorting algorithm.

Space Factor  − Space is measured by counting the maximum memory space required by the algorithm.

Suppose   X  is an algorithm and  n  is the size of input data, the time and space used by the algorithm X are the two main factors, which decide the efficiency of X .

##### Scene 17 (5m 51s)

Introduction

VARIABLES

In general understanding, a Variable is that quantity whose value is not necessarily fixed(i.e. it can change)during the operation. Unlike a Constant whose value cannot change.

##### Scene 18 (6m 6s)

Use of Variables in C.

Usually in algebra it is used to represent and then finally find an unknown value. But in programming languages like C, Variables are fixed blocks of memory with a valid identifier. And without contradicting the essential nature of a variable, here too the value of a variable is subject to change depending on the algorithm of the program, during the it’s execution. A variable in C has a name & it’s type.

Which is nothing but a unique ‘identifier’.

It is the type of value stored in that block of memory which is accordingly of a particular size.

##### Scene 19 (6m 44s)

How to ‘name’ a variable in C?

An ‘identifier’ is a unique name that references to a memory location, so that it can be called anytime during the execution of the program. Just like any other identifier, name of a variable in C is constructed by combining letters(both upper case & lower case), digits(0-9) & underscore(_), and can be limitlessly long. But then there are rules as follows— Cannot be any of the keywords(there are 32 of them in C) First character must be non digit. White spaces are not allowed in the name.

It is also important to note the subtle differences between Declaring & Defining a variable.

##### Scene 20 (7m 23s)

DECLARATION A variable or a function can be declared any numbers of times. Memory will not be allocated during declaration. Int f(int); In the above function declaration. This declaration is just for informing the compiler that a function named f with return type and argument as int will be used in the function.

DEFINATION A variable or a function can be defined only once. Memory will be allocated. Int f(int a) The system allocates memory by seeing the above function definition.

VARIABLE DECLARATION :- it refers to that part where a variable is first time declared before the compiler, prior to its use in the program. VARIABLE DEFINATION :- it is that part where the variable is assigned a value .

##### Scene 21 (8m 4s)

On the basis of the scope of the variable, further it can be of following types

Local Variable Global Variable Static Variable Automatic Variable External Variable

Scope in any program is a region of the program where a defined variable can have its existence and beyond that, particular variable it cannot be accessed.

##### Scene 22 (8m 28s)

LOCAL

A variable that is declared inside the function or block is called a local variable. It must be declared at the start of the block. void  function1()  We must have to initialize the local variable before it is used .

A variable that is declared outside the function or block is called a global variable. Any function can change the value of the global variable. It is available to all the functions. It must be declared at the start of the block. int  value =20 ;//global variable   void  function1()

GLOBAL

##### Scene 23 (9m 6s)

STATIC

A variable that is declared with the ‘static ’ keyword is called static variable. It retains its value between multiple function calls. void  function1() If you call this function many times, the local variable will print the same value for each function call, e.g , 11,11,11 and so on. But the static variable will print the incremented value in each function call, e.g. 11, 12, 13 and so on.

##### Scene 24 (9m 46s)

EXTERNAL

We can share a variable in multiple C source files by using an external variable. To declare an external variable, you need to use ’extern’ keyword . extern  int  x=10 ;//external variable (also global)

All variables in C that are declared inside the block, are automatic variables by default. We can explicitly declare an automatic variable using  ’auto’ keyword. void  main()

AUTOMATIC

##### Scene 25 (10m 16s)

What do we actually mean by the ‘data type’ of a variable?

C language has some predefined sets of data, each of which makes a particular ‘data type’. The value stored in form of a variable will occupy a certain amount of memory according to the data type it belongs, and is stored in the associated memory block of a particular size. One can easily understand why assigning a smaller block is not a good idea. But neither is assigning an unnecessarily big block for a given variable, since more the occupation of the available memory, slower the execution of the program.

Primitive data types :- these data types are built-in/predefined data types and therefore can be used directly by the user to declare variables. Derived data types :- derived from the primitive data types. Abstract/User defined :- these data types are defined by user itself.

Although Derived & User-defined data types are not actually in the scope of our discussion here .

##### Scene 26 (11m 26s)

Following are the examples of some very common data types used in C: char:  The most basic data type in C. It stores a single character and requires a single byte of memory in almost all compilers. Can be signed OR unsigned. int:  As the name suggests, an int variable is used to store an integer. Can be signed OR unsigned. And depending on the size of the integer, ‘short ’ < ‘int’ < ‘long’ are used. float:  It is used to store decimal numbers (numbers with floating point value) with single precision. Once again, depending upon the size of the decimal number, ‘float’ < ‘double’ < ‘long double’ are used

char unsigned char short unsigned short unsigned int lone Unsinged long float double lone double 1 1 2 2 2 4 8 10 .128to 127 Oto 255 -32,768 to 32,767 O to 65535 32,768 to 32,767 Oto 65535 -2147483648 to +2147483647 O to 4294967295 -3.4+38 to +3.4+38 1.7 e-308 to 1.7 ee308 3.a +4932 to 1.1 e.a932 % If

##### Scene 27 (12m 23s)

REGARDS ARITRA SONGIRI HIMANSHU KUMAR PRASAD MOUMITA SARKAR MAUSUMI SAMAL PAYEL MANNA