0% found this document useful (0 votes)
31 views113 pages

Chapter 1-7 Full Chapter Revision

The document provides an overview of structures and pointers in C++, including definitions, syntax, and examples for declaring and accessing structure variables. It also covers memory allocation types, pointer operations, and the relationship between pointers and arrays, strings, and structures. Additionally, it introduces concepts of object-oriented programming and data structures, along with their operations and classifications.

Uploaded by

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

Chapter 1-7 Full Chapter Revision

The document provides an overview of structures and pointers in C++, including definitions, syntax, and examples for declaring and accessing structure variables. It also covers memory allocation types, pointer operations, and the relationship between pointers and arrays, strings, and structures. Additionally, it introduces concepts of object-oriented programming and data structures, along with their operations and classifications.

Uploaded by

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

Structures and Pointers

- -
Chapter 1

1
Structure
• Structure is a user-defined data type of C++ to represent a collection
of logically related data items, which may be of different types, under
a common name.
• Hetrogeneous Datatype
• User defined Datatype
Structure Example and Syntax
struct student struct structure_tag
{ {
data_type variable1;
int adm_no;
data_type variable2;
char name[20];
...................;
char group[10]; data_type variableN;
float fee; };

};
Declaring Structure Variables
• Variables should be declared for storing the details.

• Structure variable is declared using the following syntax:

• struct structure_tag var1, var2, ..., varN;

• Or

• structure_tag var1, var2, ..., varN;


Structure Variable Initialisation
student s = {3452, "Vaishakh", "Science", 270.00};
Accessing Structure Elements
• The dot operator (.) connects a structure variable and its
element using the following syntax:

• structure_variable.element_name

• Examples for accessing elements of a structure :

• cin >> st.adm_no;

• st.fee = 2500;

• gets(st.name);

• cout << st.group;


Nested Structure
• An element of a structure may itself be another structure.

• Such a structure is known as nested structure


struct student
{
int adm_no;
char name[20];
struct dob
{
int day;
int month;
int year;
}dt ;
float fee;
} st ;
Array V/S Structures
Array Structure
It is a derived data type It is a user defined data type
A Collection of same type data A collection of different type data
Elements of array are Elements of structure are
referenced using referenced using dot operator (.)
corresponding subscripts
When an element of an array When an element of a structure
becomes another array, multi- becomes
another structure, nested structure is
dimensional array is formed
formed.
Pointer
• Pointer is a variable that can hold the address of a memory
location.

• &

• *
Declaration of Pointer Variables
• Syntax to declare pointer variable:

• data_type * variable;

• Examples:

• int *ptr1;

• float *ptr2;

• struct student *ptr3;


Two types of Memory Allocation
Static Memory Allocation Dynamic Memory Allocation

Takes place before the execution of Takes place during the execution of
the program the program

No operator is needed for Allocation new Operator is used for Allocation

No Operator is needed for de- delete Operator is used for de-


allocation allocation
Pointer is not needed Pointer is essential

Data is referenced using variables Data is referenced using Pointers


Example
• Ensure that the memory allocated through new is properly de-
allocated through delete.

Memory Leak
Operations on Pointers
• Arithmetic

• Relational

13
Pointer and Array
• ar[10];

• ptr = &ar[0];

• cout<<ptr;

• cout<<*ptr;

• cout<<(ptr+1);

• cout<<*(ptr+1);

• cout<<(ptr+9);

38
• cout<<*(ptr+9);
Dynamic Array
• Collection of memory locations created during run time using
the dynamic memory allocation operator new.

• The syntax is:

=
• pointer = new data_type[size];

• Here, the size can be a constant, a variable or an integer


expression
new int [10];
int *
=

+ *
P
= New int [x];
Pointer and String
• Strings can be referenced using character pointer

• Eg:

• char *str;

• str = “hello”;

• cout<<str;
Pointer and Structure
struct employee

{
int ecode;

char ename[15];

float salary;

};

employee *eptr;

eptr = new employee;

17
Pointer and Structure
• Accessing structure elements using structure pointer

• structure_pointer->element_name; -
>

• structure_variable.element_name;

18
Self Referential Structure
struct employee

{
int ecode;

char ename[15];

float salary;

employee *ep;

};

19
Self Referential Structure
• Structure in which one of the elements is a pointer to the same
structure

• A location of this type contains data and the address of another


location of the same type

20
Questions
struct
1. ………… keyword is used to specify a structure.

2. Given int *P, x = 35; P = &x; what is the value of *P? ⑲


3
execution
3. Dynamic allocation means memory allocation at the time of ……

4. The ‘new’ operator should be matched with a ……….


delete

5. Name the unary operator that returns the address of its operand. &
base address
6. The address of the first byte is known as…………
nested structu
7. Structure within a structure is termed as ....................
Questions
8. What does the following statement mean?
int *P = new int [10];

9. Orphaned memory blocks are undesirable. How can they be


avoided OR Discuss problems created by memory leaks.

10.Write C++ statement for the following.


1.To declare an integer variable named ‘x’ using new operator.
2.To initialize the integer pointer variable x with value 5.
3.To declare a dynamic array of ten integers named x.
Questions
11. .Define a structure called time to group the hours, minutes and seconds.
- -- -

Also write a statement that declares two variables current-time and next-time
which are of type struct time time current- time, next time
;

②②
12.Compare the aspects of arrays and structures.

Sore question new


13.Run time allocation of memory is triggered by ................ operator.
14.State any two differences between static and dynamic memory allocation
-

--

15. .Write the use of * and & operators used in pointer


Concepts of Object Oriented
Programming
Chapter 2

54
Procedure-Oriented Programming
• Procedure- Oriented Languages : C, Pascal, FORTRAN, BASIC

• Procedural languages: Top-down languages

25
Object-Oriented Programming (OOP) Paradigm
• Data and Functions that operate on that data into a single unit -
Object

26
Basic concepts of OOP
• Objects

• Classes

• Data Abstraction

• Data Encapsulation

• Modularity

• Inheritance

• Polymorphism
27
Objects
• Objects have properties (also called member/data/state) and behaviour
(also called methods/member functions)

Classes
• An object is defined via its class which determines everything about an
object.

• A class is a prototype/blue print that defines the specification common


to all objects of a particular type.

28
• This specification contains the details of the data and functions that
act upon the data.
Data Abstraction
• Showing only the essential features of the application and hiding the details
from outside world

Data Encapsulation
Encapsulation is an OOP concept that binds together the data and functions that
manipulate the data, and keeps both data and function safe from outside interference
and misuse.

Access specifiers

Private : Not visible outside the class – default

29 Protected : visible to its derived class also but not outside the class.

Public : Visible everywhere


Modularity

solve a problem by decomposing the problem into small


sub-problems and then try to solve each sub-problem separately.

Modularity is a concept through which a program is partitioned


into modules that can be considered and written on their own,
with no consideration of any other module

30
Inheritance
Process by which objects of one class acquire the properties and
functionalities of another class.

Inheritance supports the concept of hierarchical classification and


Reusability

Once a class is written, created and debugged, if needed, it can be distributed


for use in other programs – reusability

31
Inheritance
Existing class is called the base class

New class is referred to as the derived class

class derived_class: AccessSpecifier base_class

//declaration of members and member functions

};
32
Types of Inheritance

33
Polymorphism
'Poly' means many.

'Morph' means shapes.

Polymorphism - ability to express different forms

34
PolymorphismTypes

35
Questions
1.________ protect data from unauthorized access.
(a) Polymorphism (b) Encapsulation (c) Data abstraction
2. Write any two advantages of Object Oriented Programming
3. What do you mean by Inheritance in C ++?
4. Explain data abstraction with an example.
5. Compare Procedural programming with Object-oriented
programming.
6. Define Polymorphism. What are its types?
Data Structures and Operations
Chapter 3

1
Data Structure
• Particular way of organizing similar or dissimilar logically
related data items which can be processed as a single unit

• Allow the user to combine various types of data

• Allow processing of the group as a single unit.

3
8
Classification of Data Structures

3
9
Operations on Data Structures
• Data represented by the data structures are processed by certain
operations

• Traversing
• Searching
• Inserting
• Deleting
• Sorting
• Merging
40
Stack
• DS follows LIFO (Last In First Out) principle

• Insertions and deletions made only on one end – top of the stack

41
Algorithm
Start

1: If (TOS < N-1) Then //Space availability checking (Overflow)

2: TOS = TOS + 1

3: STACK[TOS] = VAL

4: Else

5: Print "Stack Overflow "


6: End of If

Stop
Algorithm: Pop
• Start

• 1: If (TOS > -1) Then //Empty status checking (Underflow)


• 2: VAL = STACK[TOS]

• 3: TOS = TOS - 1
• 4: Else
• 5: Print "Stack Underflow "
• 3: End of If

• Stop
Queue
• Queue follow the First-In-First-Out (FIFO) principle

• Two ends- front and rear

• Insertion operation – rear

• Deletion operation - front

44
Algorithm
Start

1: If (REAR == -1) Then //Empty status checking

2: FRONT = REAR = 0

3: Q[REAR] = VAL

4: Else If (REAR < N-1) Then //Space availability checking

5: REAR = REAR + 1

6: Q[REAR] = VAL

7: Else
8: Print "Queue Overflow "

9: End of If
43

Stop
Algorithm: Deletion
Start
1: If (FRONT > -1 AND FRONT <= REAR) Then // Empty status checking
2: VAL = Q[FRONT]
3: FRONT = FRONT + 1
4: Else
5: Print "Queue Underflow "
6: End of If
7: If (FRONT > REAR) Then // Checking the deletion of last element
8: FRONT = REAR = -1
9: End of If
Stop
46
Linked list

52
Linked List
• Collection of nodes

• Each node contains data and link(pointer to next node in the list)

• Start or Header and it contains the address of the first node

48
Implementation of Linked List
struct Node

int data;

Node *link;

};

49
Questions
1.Briefly explain classification of data structure.

2. Give name of two non-linear data structures.


3. Compare static and dynamic data structure.

4. Queue follows FIFO and Stack follows LIFO principles. Justify.

5. Write algorithm for push operation in a stack.


6. Write algorithm for deleting an item from a queue.
Web Technology
CHAPTER - 4
Static web page V/s Dynamic web page

2
Client side scripting V/s Server side scripting

3
Cascading Style Sheet
• Cascading Style Sheets (CSS) is a style sheet language used for
describing the formatting of a document written in HTML.
• Using CSS, we can control the colour of the text, the style of fonts, the
spacing between paragraphs, how columns are sized and laid out,
borders and its colours, what background images or colours are used,
as well as a variety of other effects in a web page.

4
HTML document and Web page
• HTML
• Hyper Text Markup Language
• Used to create Webpages

HTML Tags & Attributes

5
Essential HTML Tags O
Imp
En
-
I,
Tag Description Type Attributes Ar, ,

- -
it
<html> Container Tag Lang etc,
Dir ~
<head> Container Tag -
<title> Container Tag -
<body> Container Tag Bgcolor

]
Text
Background

=
Link
Alink
Vlink
-
P
Leftmargin
6
Topmargin
Some Common Tags
N0. Tag Description E/C Attribute
1 <h1>………..<h6> Container Align
Tag
Example:

2 <p> Container Align


Tag
Example

7
Some Common Tags
N0. Tag Description E/C Attribute
3 <br> Empty
Tag
Example:

4 <hr> Empty Width


Tag Size
Color
Align
noshade
Example

8
Some Common Tags
N0. Tag Description E/C Attribute
5 <center> Container
Tag
Example:

9
Some Common Tags
N0. Tag Description E/C Attribute
6 <b> Container Tag
<i>
<u>
<s>
<big>
<small>
<strong>
<em>
<sub>
<sup>
<q>
<blockquote>
Example:

0
Some Common Tags
N0. Tag Description E/C Attribute
7 <pre> Container
Tag
Example:

8 <address> Container
Tag
Example

1
Some Common Tags
N0. Tag Description E/C Attribute
9 <marquee> Container Height
Tag Width
Bgcolor
Scrollamount
Scrolldelay
Loop
direction
Example:

2
Some Common Tags
N0. Tag Description E/C Attribute
10 <font> Container Size
Tag Color
face
Example:

3
Reserved characters

4
Comments in HTML document
Any content placed within the tag
<!-- -->
will be treated as a comment and will be completely ignored by the browser

5
Inserting Images
Tag Description E/C Attribute
<img> Empty Tag Border
Bordercolor
Height
Width
Src
Align(TMB)
Example

6
Questions
1. HTML Stands for………………………………………
2. What is a container tag ? Write an example.
3. The type of tag that requires only a starting tag but not an ending tag is
called ...............
4. For scrolling a text, we use ................ tag.
5. ……………….is the main attribute of <img> tag
6. Expand DNS.
7. A Domain Name System returns the .................. of a domain name.
8. Expand HTTPS.
Questions
9. Compare static and dynamic webpages.
10. What are the differences between client side and server side scripts ?
11. Write the service associated with the following software port number.
a) 25 b) 80 c) 443
12. Write the basic structure of HTML document.
13. Write the use of the following tags.
(a) <B> (b) <I> (c) <U> (d) <Q>
14. Classify the following into tags and attributes :
(a) BR (b) WIDTH (c) LINK (d) IMG
15. Write the names of any three attributes of <BODY>
Web Designing Using HTML
CHAPTER - 5
List
Type Tag Description E/C Attributes

Unordered List <ul> Symbols Container Type


Tag
Ordered List <ol> Number/ Container Type
Letter/Roman Tag Start

Definition List <dl> Space/indendation Container <dt>


Tag <dd>

0
Links in HTML
• A hyperlink (or simply link) is a text or an image in a web page that we can
click on, and move to another document or another section of the same
document.
• The <a> tag, called anchor tag is used to give hyperlinks.

• Href is the main attribute of tag.

• Internal Linking
• External Linking
• Graphical Linking
• Email Linking
1
Inserting Audio Video
Tag Description E/C Attribute
<embed> Container Src
Tag Height
Width
align

Tag Description E/C Attribute


<bgsound> Container Src
Tag Loop

2
Table
Tag Description E/C Attribute
<table> To create table Container Tag Border Border color,
Bgcolor , Background,
Height , Width, align,
Cellspacing, cellpadding

Supporting Tags:
<tr>
<th>
<td>
3
Supporting Tag:
Tag Description E/C Attribute
<tr> Table Row Container Tag Bgcolor
Align
Valign
<th> Table Heading Container Tag Bgcolor
Align Valign
Colspan Rowspan
<td> Table data Container Tag Bgcolor
Align Valign
Colspan Rowspan

4
Dividing Browser Window
Tag Description E/C Attribute
<frameset> To partition the Container Cols
browser window Tag Rows
into different frame Border
sections.
<frame> Define the frame Container Src
Tag name

5
Forms in Web Pages
• HTML Forms are used to collect data from the webpage viewer for
processing.
• A Form consists of two elements:
• <FORM> container tag
• Form controls like text boxes, textarea fields, drop-down menus, radio buttons,
checkboxes, etc.

6
Supporting Tag: <tr>
Tag Description E/C Attribute
<form> To provide a container for Container Tag Action
form control method

7
Supporting Tag: <input>
Tag Description E/C Attribute
<input> Different type of control Empty Tag Type

Name
Value
8
Size
Maxlength
Supporting Tag: <textarea>
Tag Description E/C Attribute
<textarea> Text in more than one Container tag Name
line Rows
Cols

Supporting Tag: <select>


Tag Description E/C Attribute
<select> Text in more than one Container tag Name
line size
multiple
9 <option> To specify the items in Empty tag Value
the select list Selected
Questions
1. What are the different types of lists in HTML?
2. Which are the attributes of <OL>tag ? Write their default values.
3. Write HTML code to get the following output using ordered list

4. Write the HTML code to display the following using list tag:
• Biology Science
• Commerce
• Humanities
Questions
5. What is a definition list ? Which are the tags used to create definition list ?
6. What is a hyperlink ? Which is the tag used to create a hyperlink in HTML
document ?
7. Name any two associated tags of <TABLE> tag.
8. List out some attributes of <table> tag
9. Write HTML program to create the following webpage :
Questions
10. Write any two attributes of <TR> tag.
11. Choose the odd one out:
a. TABLE b. TR c. TH d. COLSPAN
12. Which among the following is an empty tag?
(a) <TABLE> (b) <FRAMESET> (c) <FRAME> (d) <FORM>
13. What is the use of frame tag in HTML ?
14. List out any 4 important values of TYPE attribute in the <INPUT> tag

15. Write any three attributes of <INPUT> tag.


Client Side Scripting Using
JavaScript
Chapter - 6
Introduction
Client side scripting language:
JavaScript
VB script
Server side scripting language :
PHP
ASP
JSP
<script> tag
- used to add script
- Used for data validations in the Forms at the client side.
- container tag
- attribute: - Language ( Value: JavaScript)
- Syntax
<script Language = “JavaScript”>
……….
</script>
<html>
<head>
<title> sample </title>
</head>
<body>
<SCRIPT Language= "JavaScript">
document.write("Welcome to JavaScript.");
</SCRIPT>
</body>
</html>
2. Functions in JavaScript
Syntax:
function funcname()
{
--------------------
--------------------
--------------------
}
3. Datatypes in JS
• Number
- All numbers ( integer, float)
- eg:
• String
- Group of characters, enclosed in double quotes.
-eg:
• Boolean
-Contain only two values
-true and false
7
4. Variables in JS
• Variables are used for storing values.
• Using the keyword: var
Eg: var x,y,z;
x=10;
y=“eduport”;
z=true;
#typeof()- Returns data type
5. Operators
 Arithmetic: + - * / %
 Relational: < <= > >= == !=
 Logical: && || !
 Assignment: =
 Increment / Decrement: ++ --
 String concatenation: +
6. Control Statements
 if
 if … else
 else if ladder
 nested if
 switch
 for
 while
 do ..while
 break
 continue
7. Built in Function
• alert () - print a dialogue box
alert(“Welcome”);

• isNaN () - NaN stands for Not a Number


• isNaN () - true

• - false
• toUpperCase () - used to convert given string into uppercase.

• toLowerCase () - used to convert given sting into Lowercase

• charAt() - Return character at a particular position

• length - Return length of string


8. Accessing values from the input

Variable=document.formname . textbox name . value


- -- - -

-
onClick
onMouseEnter
t -

Even
-
onMouseLeave
- -

onKeyUp
-
onKeyDown
-
MULTIPLICATION
<script Language=JavaScript>
function ……………………..
{
var a,b,c;
a=Number(document.frm.n1.value);
b=Number(document.frm.n2.value);
…………………
document.frm.n3.value=c;
}
</script>
CUBE
<script Language=JavaScript>
function ……………………………….
{
var a,b;
a=Number(document.frm.n1.value);
b=a*a*a;
document.frm.n2.value=b;
}
</script>
Ways to add script
 Inside body section
 Scripts will be executed while the content of the web page is being loaded.

 Inside head section


 We can place the script inside <HEAD> section.
 It helps to execute scripts faster as the head section is loaded before the BODY
section.
 But the scripts that are to be executed while loading the page will not work .

 External file
 Scripts can be placed into an external file ,saved with .’js’ extension.
 It can be used by multiple HTML pages and also helps to load pages faster.
 The file is linked to HTML file using the <SCRIPT> tag.
Questions
1.Which tag is used to include script in an HTML page?
2. What are the Data Types in Javascript?

3. Explain the operators in javascript.

4. Explain some common JavaScript events.


5. Explain Built - in Functions in JavaScript

6. Write the syntax to declare a variable in Java Script with one example.
Questions
7. What are the different methods for adding Scripts in an Html Page?

8. Write JavaScript functions to perform the following :


(a) To check whether a value is number or not.
(b) To return the upper case form of given string.
(c) To return the character at a particular position.
Chapter 7
Web Hosting
Web hosting
• Service of providing storage space in a web server for the files of a
website.
• The companies that provide web hosting services are called web
hosts.

8
Types of Hosting
• The selection of web hosting type depends on
(i) Amount of storage space
(ii) Number of expected visitors
(iii)Data base requirement
(iv) Support of programming languages.

There are three types of web hosting


Shared hosting
Dedicated hosting
VPS
9
Shared Hosting
• Many different websites are stored on one single web server and
they share resources like RAM and CPU.
• Most suitable for small websites that have less traffic.
• Shared servers are cheaper
• Easy to use.
• A drawback is that the bandwidth is shared by several websites and
hence their services will be slow

00
Dedicated Hosting
• The client leases the entire web server and all its resources.
• It is not shared.
• Websites of large organizations, government departments, etc.
where there are large numbers of visitors, opt for dedicated
web hosting.
• Dedicated servers provide fast access.
• Expensive.

01
VPS
• VPS : Virtual Physical Server
• It is virtually partitioned into several servers.
• Each VPS works similar to a dedicated server and has its own
separate server operating system

• It provides dedicated amount of RAM for each virtual web server.

• Suitable for websites that require more features than shared


hosting, but does not require all the features of dedicated hosting.

• Some popular server virtualization softwares are VMware, FreeVPS,


02
etc.
Free Hosting
• Free hosting provides web hosting services free of charge.
• Low Security
• The size of the files that can be uploaded may be limited.

• Provide Advertisement to meet their expense


• Provide only Sub domain
• No customer care Support

• Sites.google.com, yola.com, etc. are free web hosting services.

03
CMS
• Content Management System (CMS) refers to a web based software
system which is capable of creating, administering and publishing
websites.
• CMS provides an easy way to design and manage attractive websites.
• Templates are available for download.
• Advantages:
• CMS provides standard security features in its design.
• Help people with less technical knowledge to design and develop secure websites.
• The templates reduce the need for repetitive coding and design for headings and menus
that appear in all pages in a website
• CMS is economical
04
• Some of the popular CMS software are WordPress, Drupal and Joomla!
Responsive Web Design
• Responsive web design is the custom of building a website suitable
to work on every device and every screen size, no matter how large
or small, mobile phone or desktop or television.
• Responsive web design can be implemented using flexible grid
layout, flexible images and media queries.
• Flexible grid layouts set the size of the entire web page to fit the
display size of the device.
• Flexible images and videos set the image/video dimensions to the
percentage of display size of the device.

05
Questions
1. Explain the different types of Web Hosting.

2. What is Content Management System ?

3. Explain the need for applying responsive web design while developing
websites

4. What is free hosting?

You might also like