C M M Theory
C M M Theory
Machine code or machine language is a set of instructions executed directly by a computer's central
processing unit (CPU). Each instruction performs a very specific task, such as a load, a jump, or an
ALU operation on a unit of data in a CPU register or memory. Every program directly executed by a
An assembly language (or assembler language) is a low-level programming language for a computer,
or other programmable device, in which there is a very strong (generally one-to-one) correspondence
between the language and the architecture's machine code instructions. Assembly language is
converted into executable machine code by a utility program referred to as an assembler; the
High-level language is any programming language that enables development of a program in much
simpler programming context and is generally independent of the computer's hardware architecture.
High-level language has a higher level of abstraction from the computer, and focuses more on the
programming logic rather than the underlying hardware components such as memory addressing and
register utilization.
The first high-level programming languages were designed in the 1950s. Now there are dozens of
different languages, including Ada , Algol, BASIC, COBOL, C, C++, JAVA, FORTRAN, LISP,
Pascal, and Prolog. Such languages are considered high-level because they are closer to human
languages and farther from machine languages. In contrast, assembly languages are considered low
In the procedure oriented approach, the problem is viewed as sequence of things to be done such as
Procedure oriented programming basically consist of writing a list of instruction or actions for the
computer to follow and organizing these instruction into groups known as functions.
3. No data hiding
creating partitioned memory area for both data and functions that can be used as templates for
3. Data structures are designed such that they characterize the objects.
4. Functions that operate on the data of an object are tied together in the data
structure.
1. Objects
2. Classes
4. Inheritance
5. Polymorphism
6. Dynamic binding
7. Message passing
BENEFITS OF OOP:
Oop offers several benefits to both the program designer and the user. Object-oriented contributes to
the solution of many problems associated with the development and quality of software products.
1. Through inheritance we can eliminate redundant code and extend the use of existing
classes.
2. We can build programs from the standard working modules that communicate with one
another, rather than having to start writing the code from scratch. This leads to saving of
4. It is possible to have multiple instances of an object to co-exist with out any interference.
7. Message passing techniques for communication between objects makes the interface
APPLICATION OF OOP:
The most popular application of oops up to now, has been in the area of user interface
design such as windows. There are hundreds of windowing systems developed using oop
techniques.
Real business systems are often much more complex and contain many more objects
with complicated attributes and methods. Oop is useful in this type of applications because it
can simplify a complex problem. The promising areas for application of oop includes.
OBJECTS
An Object is an instance of a class. Objects are the basic run-time entities in an object-oriented system.
They may represent a person, a place, a bank account, a table of data or any item that the program must
handle. The fundamental idea behind object oriented approach is to combine both data and function
into a single unit and these units are called objects.
The term objects means a combination of data and program that represent some real word
entity. For example: consider an example named Amit; Amit is 25 years old and his salary is 2500.
The Amit may be represented in a computer program as an object. The data part of the object would
The program part of the object may be collection of programs (retrive of data, change age,
change of salary). In general even any user –defined type-such as employee may be used. In the
Amit object the name, age and salary are called attributes of the object.
CLASS:
A group of objects that share common properties for data part and some program part are
In C ++ a class is a new data type that contains member variables and member functions that
# include<iostream.h>
class person
char name[30];
int age;
public:
void getdata(void);
void display(void);
};
cout<<”enter name”;
cin>>name;
cout<<”enter age”;
cin>>age;
void display()
cout<<”\n name:”<<name;
cout<<”\n age:”<<age;
int main( )
person p;
p.getdata();
p.display();
return(0);
DATA ABSTRACTION :
Abstraction refers to the act of representing essential features without including the back
ground details or explanations. Classes use the concept of abstraction and are defined as size, width
encapsulation. The data is not accessible to the outside world and only those functions which are
wrapped in the class can access it. These functions provide the interface between the objects data and
the program.
INHERITENCE :
Inheritance is the process by which objects of one class acquire the properties of another
class. In the concept of inheritance provides the idea of reusablity. This mean that we can add
additional features to an existing class with out modifying it. This is possible by desining a new class
POLYMORPHISIM:
Polymorphism means the ability to take more than one form. An operation may exhibit different
instance. The behaviour depends upon the type of data used in the operation.
A language feature that allows a function or operator to be given more than one definition. The types
of the arguments with which the function or operator is called determines which definition will be
used.
It is able to express the operation of addition by a single operater say ‘+’. When this is possible you
use the expression x + y to denote the sum of x and y, for many different types of x and y; integers ,
float and complex no. You can even define the + operation for two strings to mean the concatenation
of the strings.
DYNAMIC BINDING :
Binding refers to the linking of a procedure call to the code to the executed in
response to the call. Dynamic binding means the code associated with a given procedure call is not
known untill the time of the call at run-time. It is associated with a polymorphic reference depends
C++ Comments:
C++ introduces a new comment symbol //(double slash). Comments start with a
double slash symbol and terminate at the end of line. A comment may start any where in the line and
what ever follows till the end of line is ignored. Note that there is no closing symbol.
The double slash comment is basically a single line comment. Multi line comments can be
written as follows:
// this is an example of
// c++ program
// thank you
The c comment symbols /* ….*/ are still valid and more suitable for multi line comments.
Output Operator:
The statement cout <<”Hello, world” displayed the string with in quotes on the screen. The identifier
cout can be used to display individual characters, strings and even numbers. It is a predefined object
that corresponds to the standard output stream. Stream just refers to a flow of data and the standard
Output stream normally flows to the screen display. The cout object, whose properties are defined in
iostream.h represents that stream. The insertion operator << also called the ‘put to’ operator directs
Return Statement:
In C++ main ( ) returns an integer type value to the operating system. Therefore every main (
) in C++ should end with a return (0) statement, otherwise a warning or an error might occur.
Input Operator:
The statement
cin>> number 1;
is an input statement and causes. The program to wait for the user to type in a number. The number
keyed in is placed in the variable number1. The identifier cin is a predefined object in C++ that
corresponds to the standard input stream. Here this stream represents the key board.
The operator >> is known as get from operator. It extracts value from the keyboard
cout<<”sum=”<<sum<<”\n”<<”average=”<<average<<”\n”;
cin>>number1>>number2;
IDENTIFIERS:
Identifiers refers to the name of variable , functions, array, class etc. created by programmer. Each
7) since C is a case sensitive, the upper case and lower case considered
differently, for example code, Code, CODE etc. are different identifiers.
net_salary, age, data etc. An identifier name may be long, some implementation
In ANSI C the maximum length of a variable is 32 chars but in c++ there is no bar.
The type void normally used for:
1) To specify the return type of function when it is not returning any value.
Example:
Void function(void);
CONSTANTS
Constant is a any value that cannot be changed during program execution. In C,
of 2 bytes and max 4 bytes. It may be positive or negative but by default sign is
always positive. No comma or space is allowed within the numeric constant and it
must have at least 1 digit. The allowable range for integer constants is -32768 to
32767. Truly speaking the range of an Integer constant depends upon the compiler.
For a 16-bit compiler like Turbo C or Turbo C++ the range is –32768 to 32767.
For a 32-bit compiler the range would be even greater. Mean by a 16-bit or a 32-
bit compiler, what range of an Integer constant has to do with the type of compiler.
whole number which have no decimal point. Types of integer constants are:
In decimal constant first digit should not be zero unlike octal constant first digit
must be zero(as 076, 0127) and in hexadecimal constant first two digit should be
0x/ 0X (such as 0x24, 0x87A). By default type of integer constant is integer but if
the value of integer constant is exceeds range then value represented by integer
mention integer and unsigned integer type by suffix l/L and u/U.
Real constant is also called floating point constant. To construct real constant we
-No commas or blanks are allowed within a real constant. Ex.: +325.34
426.0
-32.76
number is written in mantissa and exponent form separated by e/E. Exponent can
be positive or negative integer but mantissa can be real/integer type, for example
Character constant
22 *Under revision
quote. These can be single digit, single special symbol or white spaces such as
‘9’,’c’,’$’, ‘ ’ etc. Every character constant has a unique integer like value in
machine’s character code as if machine using ASCII (American standard code for
information interchange). Some numeric value associated with each upper and
String constant
Set of characters are called string and when sequence of characters are
enclosed within a double quote (it may be combination of all kind of symbols) is a
string constant. String constant has zero, one or more than one character and at the
examples are “,sarathina” , “908”, “3”,” ”, “A” etc. In C although same characters
are enclosed within single and double quotes it represents different meaning such
as “A” and ‘A’ are different because first one is string attached with null character
at the end but second one is character constant with its corresponding ASCII value
is 65.
Symbolic constant
Symbolic constant is a name that substitute for a sequence of characters and,
23 *Under revision
#define MAX 10
#define CH ‘b’
OPERATORS
An operator is a symbol that tells the compiler to perform specific mathematical or logical
manipulations. C language is rich in built-in operators and provides the following types of
operators:
• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
• Conditional operators
• Misc Operators
Arithmetic operator:
These are used to perform mathematical calculations like addition, subtraction, multiplication,
division and modulus.
Relational Operators:
These operators are used to perform logical operations on the given two variables.
Bitwise Operators
Bitwise operator works on bits and performs bit-by-bit operation. Bitwise operators are used in bit
level programming. These operators can operate upon int and char but not on float and double.
Showbits( ) function can be used to display the binary representation of any integer or character
value.
Bit wise operators in C language are; & (bitwise AND), | (bitwise OR), ~ (bitwise OR), ^ (XOR),
In C programs, values for the variables are assigned using assignment operators.
int a = 5, b = 3;
In C, ++ and – are called increment and decrement operators respectively. Both of these operators
are unary operators, i.e, used on single operand. ++ adds 1 to operand and – subtracts 1 to
When i++ is used as prefix(like: ++var), ++var will increment the value of var and then return it
but, if ++ is used as postfix(like: var++), operator will return the value of operand first and then
#include <stdio.h>
int main()
{
int c=2,d=2;
Return 0;
Output
- Linker Errors:
- Linker errors occur during the linking phase when combining object files into an executable program.
These errors include unresolved symbols or missing libraries.
- Runtime Errors:
- Runtime errors are found during program execution. They can be further classified:
- Logic Errors: Errors found by the programmer while investigating erroneous results.
- Run-time Errors: Errors detected during program execution, such as division by zero or accessing
out-of-bounds memory.
Remember that understanding and fixing these errors is essential for successful programming!