C LANGUAGE
~~~~~~~~~~
INTRODUCTION TO C:
~~~~~~~~~~~~~~~~~~~
C was originally developed 1970's by Dennis Ritche at Bell Telephone
laborataries (INC). For the purpose of to implementing the unix operating
system. It is an out growth two earlier language called BCPL & B.
CURRENT USES OF C:
~~~~~~~~~~~~~~~~~~
The C language is used for developing following application,
[Link] system
[Link] packages
[Link]
[Link]/CAM application
[Link] processor
[Link] automation
[Link] & Engineering application
C is an uncontrollable [Link] has,
*Graphical package(games)
*Stock information
*Spreadsheet(Excel-Information maintanance)
*CNC Proogram (C language)
We can maintain the information also a file.
Office organisation software computerised,
Scientiffic engineering algorithm programs.
Foxpro--> Database Management System.
Three levls:
[Link] level(0 & 1 binary)
[Link] level(keyword as keyword)
[Link] level(0 & 1 and keyword)
C is medium level language.
~~~~~~~~~~~~~~~~~~~~~~~~~~~
DATA TYPES & CODES:
~~~~~~~~~~~~~~~~~~~
Data type Code Size
========= ==== ====
Integer %d 2 bytes
Long integer%ld 4 bytes
Char %c 1 byte
Float %f 4 bytes
Double %lf 8 bytes
String %s -
DATA TYPE:
~~~~~~~~~~
string(more than alphabets)
character(single alphabet)
integer(number)
long integer(crore values)
float(decimal values)
double(long decimal values)
FORMAT OF C PROGRAM:
~~~~~~~~~~~~~~~~~~~~
//HEADER FILE DECLARATION PART.
#include<stdio.h>
#include<conio.h>
//----------MAIN PROGRAM STARTS------------
void main()
{
clrscr();
//----------DECLARATION SECTION------------
int a,b,c;
//-----------ASSIGNMENT SECTION------------
printf("Enter the value of a and b:");
scanf("%d%d",&a,//-----------COMPALICATION SECTION---------
c=a+b;
printf("Addtion of two numbers is :%d",c);
//-----------END OF THE PROGRAM-----------
getch();
}
<stdio.h>--->standard input output header file
This header file contains with printf and scanf functions.
<conio.h>--->console input output header file
This header file contains with clrscr and getch functions.
void main()->This is the function which the operating system will start
execution each and every program must have main function.
clrscr()---->clear screen
clears the current text window and places the curser in the upper
left hand corner.(at position 1,1)
VARIABLE DECLARATION:
~~~~~~~~~~~~~~~~~~~~~
All variables used in C language must declare. C variable declarations
includes with name of the variable and its data type.
Variables are used to fold given input.
PRINTF FUNCTION:
~~~~~~~~~~~~~~~~
The printf function print any set characters or numerics or strings
all output screen.
SCANF FUNCTION:
~~~~~~~~~~~~~~~
The scanf function reads values from output buffer and stored it at
supplied address.
&---->address of int a,b,c a=10 b=10
GETCH() FUNCTION:
~~~~~~~~~~~~~~~~~
This function used for get a single character from the output screen.
ARITHMETICAL OPERATORS:
~~~~~~~~~~~~~~~~~~~~~~~~
operator purpose
+ addtion
* multiplication
- subtraction
/ divison
% module
CONTROL STRUCTURES:
~~~~~~~~~~~~~~~~~~~
The control structures are used to redirect the sequential flow of
control through the program to desired locations.
IF ELSE CONDITION:
~~~~~~~~~~~~~~~~~~~
syntax for if and else:
~~~~~~~~~~~~~~~~~~~~~~~~
if(condition)
statment 1;
else
statment 2;
In the above structure staement 1 will be executed if the condition
is true otherwise statement 2 will be executed.
If more than one statement is to be executed for a condtion then we
can group them in a single group by enclosing them within {}.
The normal statement is called as a simple statement and the
statements enclosed within brackets is called as compound statement.
SWITCH CASE STATEMENTS:
~~~~~~~~~~~~~~~~~~~~~~~~
This statement is used to perform different operations based on
the different values of an expression. We can avoid the complexity
of using the if else statements.
SYNTAX:
~~~~~~~
switch(expression)
{
case <value 1>:
statement 1;
break;
case <value 2>:
statment 2;
break;
..................
..................
..................
default:
statement n;
}
If the value of the expression matches the any one of the case
values then the statements under that case will be executed.
If none of the cases are matching then the statements under the
"default" block will be executed.
FOR LOOP STATEMENTS
~~~~~~~~~~~~~~~~~~~
This control structure is used to repeat a set of instruction
for a finite number till a condition becomes false.
SYNTAX:
~~~~~~~
for(<loop counter>=<start value>;<final condition>;<increment
expression>)
LOOPING STATEMENTS:
~~~~~~~~~~~~~~~~~~~
The looping statements are used to perform any operation
repeatedly.
WHILE LOOP:
~~~~~~~~~~~
SYNTAX:
~~~~~~~
while<condition>
statement;
DO.........WHILE LOOP:
~~~~~~~~~~~~~~~~~~~~~~~
SYNTAX:
~~~~~~~
do
statement;
while(condition);
DIFFERENCE BETWEEN WHILE AND DO.....WHILE STATEMENTS:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
WHILE: DO.....WHILE
~~~~~~ ~~~~~~~~~~~~~
1. Condition is checked at the Condition is checked at the
begining itself. end of execution.
2. The statements will not be The statements will be
executed even once if the executed once if the condition
condition is
false for the is
false for the first time.
first time.
ARRAYS
~~~~~~
An array is a collection of data elements of similar type.
By the usage of arrays many elements can be accessed with a sigle
name.
In the memory of the array elements are stored in consequent memory
locations.
The individual elements of the array can be accessed using the
position of the element in the [Link] position is called as
subscript or index.
WE HAVE TWO TYPES ARRAYS,
=========================
[Link] DIMENSION ARRAY.
[Link] DIMENSION ARRAY.
DECLARATION OF AN ARRAY:
~~~~~~~~~~~~~~~~~~~~~~~~
data type <variable name>[size 1][size 2]............[size n]>
EXAMPLE:
~~~~~~~~~~
int mark[10];
int mark[10][5];
int mark[10][7][9];
The subscripts of the elements ranges 0 to -1.
We can access the individual elements as
mark[5];
mark[6][20];
mark[20][30][50];
For example mark[5]
72------->mark[0]
52------->mark[1]
65------->mark[2]
85------->mark[3]
97------->mark[4]
FUNCTIONS
~~~~~~~~~
A function is self contained program units which performs a
speciffic task. If the task has to be a performed repeatedly
many number of times of we need not repeat the same code many
number of times.
We can write the code inside a function and we can call the
function from the main program any number of times with different
input values based on the input different results will be
returned by the function to the main program.
For example cosider the formula,
ncr=n!/r!*(n-r)!
Here the calculation for the factorial of a number should be
performed three times with different [Link] of repeating
the code we can use a function to find factorial and we can call
the function three times with different inputs.
The input given to function is called a parametre or arguement.
There can be any number of function in a program.
The program starts its run time from the main function.
There are four types of functions we have,
1. function without return vallue and without arguements
2. function with return value and without arguements
3. function without return value with arguements
4. function with return value with arguements
The function which has no return value is called as a void
function.
Every function canreturn only one value to its calling function
Types of Functions in C (Explanation)
In C programming, user-defined functions are mainly classified into
four types based on:
Whether they take parameters (inputs)
Whether they return a value
Let's break them down:
✅ 1. Function with No Parameters and No Return Value
🔸 Meaning:
The function does not take any input.
It also does not return a value to the caller.
Used when you just want to perform a task, like displaying a message.
syntax:
void functionName() {
// Code to execute
}
🔸 Example:
void greet() {
printf("Hello, World!\n");
}
int main() {
greet(); // Calls the function
return 0;
}
✅ 2. Function with Parameters but No Return Value
🔸 Meaning:
The function takes input (via parameters).
It does not return a value.
Used to perform an action using provided values.
🔸 Syntax:
void functionName(type param1, type param2) {
// Code using param1 and param2
}
🔸 Example:
void printSum(int a, int b) {
printf("Sum = %d\n", a + b);
}
int main() {
printSum(4, 5); // Output: Sum = 9
return 0;
}
✅ 3. Function with No Parameters but With Return Value
🔸 Meaning:
The function does not take input.
It returns a value to the caller.
Used when a fixed or calculated value is needed.
🔸 Syntax:
type functionName() {
return value;
}
🔸 Example:
int getNumber() {
return 10;
}
int main() {
int num = getNumber();
printf("Number: %d\n", num); // Output: Number: 10
return 0;
}
✅ 4. Function with Parameters and With Return Value
🔸 Meaning:
The function takes input (parameters).
It returns a result.
Most common and flexible type.
🔸 Syntax:
type functionName(type param1, type param2) {
return result;
}
🔸 Example:
int multiply(int x, int y) {
return x * y;
}
int main() {
int result = multiply(3, 4);
printf("Product = %d\n", result); // Output: Product = 12
return 0;
}
No arguments, no return value
Arguments, no return value
No arguments, return value
Arguments and return value
STRUCTURE
~~~~~~~~~
A structure is a collection of related variables which may be of
different data types.
Structure is a user defined data type.
Structures help to organize complicated data,particularly in
large programs becaus they permit group of related variables to be
treated as a unit instead to seprate entities.
POINTERS
~~~~~~~~~
Pointer variable is a special type of variable which has a memory
[Link] address may belong to another variable.
DECLARATION OF A POINTER:
~~~~~~~~~~~~~~~~~~~~~~~~~
<data type>*<pointer name>;
EXAMPLE:
~~~~~~~~
int *a;
float *b;
char *c;
ASSIGNING ADDRESS TO A POINTER:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<pointer variable>=&<variable name>
int a*;
int *p;
a=100;
p=&a;
GETTING TO THE CONTENT FROM A POINTER:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*<pointer variable name>
INCREMENTING AND DECREMENTING POINTER
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If a pointer is incremented it is incremented by the number of bytes
occupied by the size of the data type of the pointer.
POINTERS TO THE ARRAYS
~~~~~~~~~~~~~~~~~~~~~~
IF A POINTER IS ASSIGNED TO THE ADDRESS OF THE FIRST
ELEMENT OF AN ARRAY
THEN THE ALL ELEMENTS OF THE ARRAY CAN BE ACCESSED BY
INCREMENTING OR
DECREMENTING THE POINTER.
ASSIGNING ARRAY ADDRESS TO POINTER
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<pointer> = & <array>[0];
(OR)
<pointer> = <array>;
-----------------------------------------
C++[OBJECT ORIENTED PROGRAMMING(OOPS)]
=========================================
Object Oriented Programming Was Developed Because Several Limitations
Were Discovered In Procedural Oriented Programming Approaches.
C,Pascal,Fortran,Etc.. Are Programming Languages With Structured
Programming [Link] In This Languages Is Done By Breaking
A Problem Into Smaller Units Called [Link] A Problem Becomes
Complex,Number Of Functions Or Procedures Grow Larger And Then Program
Become Unmanagable, Difficult To Understand,And [Link] We Can Avoid
All This Difficultys Using C++.
FORMAT OF C++ PROGRAM:
~~~~~~~~~~~~~~~~~~~~
//HEADER FILE DECLARATION PART.
#include<iostream.h>
#include<conio.h>
//----------MAIN PROGRAM STARTS------------
void main()
{
clrscr();
//----------DECLARATION SECTION------------
int a,b,c;
//-----------ASSIGNMENT SECTION------------
cout << "enter the value of a and b";
cin>>a>>b;//-----------COMPALICATION SECTION---------
c=a/b;
cout<<"result"<<c;//-----------END OF THE PROGRAM-----------
getch();
}
<iostream.h>---> input output header file
This header file contains with printf and scanf functions.
<conio.h>--->console input output header file
This header file contains with clrscr and getch functions.
void main()->This is the function which the operating system will start
execution each and every program must have main function.
clrscr()---->clear screen
clears the current text window and places the curser in the upper
left hand corner.(at position 1,1)
VARIABLE DECLARATION:
~~~~~~~~~~~~~~~~~~~~~
All variables must be declared before they are [Link] is just information to
the [Link] for framing the rules remain the same.
COUT FUNCTION:
~~~~~~~~~~~~~~~~
The Cout<<-To display anything on the screen
CIN FUNCTION:
~~~~~~~~~~~~~~~
The Cin>> function -To accept input from the User
GETCH() FUNCTION:
~~~~~~~~~~~~~~~~~
This function used for get a single character from the output screen.
INHERITANCE
============
Building New Derived Classes That Inherit The Data And Functions
From One Or More Previously Defined Base Classes While Possibly
Redefining Or Adding New Data And [Link] Creates A Hierarchy Of
Classes.
POLYMORPHISM
==============
Giving An Action One Name Or Symbol That Is Shared Up And Down A
Class Hierarchy With Each Class In The Hierarchy Implementing The Action In
A Way Appropriate To Itself.
OVERLOADING
=============
Another Powerful And Useful Concept Of Object Oriented Programming
Is Overloading Allows Operation With The Same Name But Different
Semantics And Different Ways Of Implementation To Be Invoked For Objects
Of Different Type.
ACCESS SPECIFIERS
=================
PUBLIC
If A Member Is Public, It Can Be Used By Any Function.
In C++, Members Of A Struct Or Union Are Public By Default.
PRIVATE
If A Member Is Private, It Can Only Be Used By Member Functions And
Friends Of The Class In Which It Is Declared. Members Of A Class Are Private
By Default.
PROTECTED
If A Member Is Protected, Its Access Is The Same As For Private. In Addition,
The Member Can Be Used By Member Functions And Friends Of Classes
Derived From The Declared Class, But Only In Objects Of The Derived
[Link] Can Override The Default Struct Access With Private Or Protected.
You Can't Override The Default Union Access.
CONSTRUCTOR
A Constructor Is A Special Type Of Function Within A Class Which Has The
Same Name Of The Class. The Constructor Will Be Automatically Invoked At
The Time Of Creating An Object For The Class. Normally The Constructor Is
Used For Initialising The Members Of A Class. The Constructor Should Not
Have Any Return Type And Must Be In Public Section.
class <classname>
{
private:
.............
public:
...........
<classname>([arguments]) //Constructor
{
.............
}
};
*/
COPY CONSTRUCTIR
The Copy Constructor Is Used For Initialising An Object With Another Object
Of The Same Class.
**Presence Of A Default Constructor Is A Must.
<CONSNAME>(<CLASSNAME> &PTR)
{
A=PTR.A;
B=PTR.B;
}
*/
DESTRUCTOR
A Destructor Is A Function Which Is Invoked When An Object Losses Its
Scope. The Destructor Releases The Memory Occupied By The Object. The
Destructor Has Same Name Of The Class With A Tilde Symbol (~) Before It.
The Destructor Must Not Have Any Arguments Or Return Value.
~<classname>()
{
set of statements
}
FUNCTION OVERLOADING
~~~~~~~~~~~~~~~~~~~~~~~~~
Function Overloading Is A Property By Which More Than One Functions Share
The Same Name. The Type And Number Of Arguments In Each Function May
Differ.
*/
Inheritance
Inheritance Is The Property By Which A Class Gets Access To The Members
Of Another Class. We Can Call The Methods Of A Class From The Inherited
Class. The Major Advantage Is The Reusability Of Code.
The "Protected" Members Of A Class Can Be Accessed By The Inherited Class.
The Main Class Is Called As A Parent Class And The Class Inheriting Data And
Code From It Is Called As The Derived Class.
The Inheritance Can Be Either In Private Or In Public Mode.
Types Of Inheritance
~~~~~~~~~~~~~~~~~~~~~
1. Single Inheritance - A Child Class Inherits From
One Parent Class
2. Multiple Inheritance - A Child Class Inherits From
More Than One Parent
3. Hierarchial Inheritance - More Than One Child Classes
Are Inheriting A
Single Parent.
4. Multilevel Inheritance - A Child Class Inherits From
A Base Class Which Already
Inherits From Another Base Class.
5. Hybrid Inheritance - An Child Class Is Derived
From A Base Class And One Or
Two Child Classes Is Called As
Hybrid Inheritance.
(1) (2) (3) (4) (5)
A A B A A A
| |___| __|__ | |
B | | | B B D
C B C | | |
C C |
|___|
|
|
E
JAVA
What is Java?
Java is a high-level, object-oriented, platform-independent programming
language developed by Sun Microsystems (now owned by Oracle). It is
designed to have as few implementation dependencies as possible.
Java Architecture
Source Code (.java)
Compiler converts code to Bytecode (.class)
JVM (Java Virtual Machine) runs the bytecode
Components:
JDK (Java Development Kit): Contains tools to develop Java programs
JRE (Java Runtime Environment): Provides libraries and JVM to run Java
apps
JVM (Java Virtual Machine): Executes the bytecode
🔹 3. Core Concepts
➤ OOP Principles in Java:
Encapsulation: Wrapping data and methods into a single unit (class)
Inheritance: One class inherits properties/methods of another
Polymorphism: Same method behaves differently in different contexts
Abstraction: Hiding implementation details and showing only functionality
🔹 4. Basic Syntax
public class HelloWorld {
public static void main(String[] args) {
[Link]("Hello, World!");
}
}
🔹 5. Data Types
Primitive Types: int, float, char, boolean, byte, short, long, double
Reference Types: Objects, Arrays, Strings, etc.
🔹
6. Control Structures
if, else if, else
switch
for, while, do-while loops
break, continue, return
🔹 7. Exception Handling
Used to handle runtime errors.
try {
// risky code
} catch (Exception e) {
// error handling
} finally {
// always executed
}
🔹
8. Java API and Packages
Java provides built-in packages like:
[Link] (automatically imported)
[Link] (collections, date, etc.)
[Link] (input/output)
[Link] (networking)
You can also create your own packages.
Multithreading
Java allows multiple threads of execution.
Thread t = new Thread(() -> {
[Link]("Thread is running");
});
[Link]();