The document provides information about pointers in the C programming language. It discusses pointer declaration, definition, initialization, dereferencing, arithmetic operations like incrementing and decrementing, and relationships between arrays and pointers. It also covers dynamic memory allocation functions like malloc(), calloc(), free(), and realloc(). Pointers allow accessing and manipulating data in memory and performing tasks like dynamic memory allocation.
Introduction, Array of structure, Passing structure to function, Passing array of structure to function, Structure within structure ( Nested Structure), Union, Pointer to structure
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
Introduction, Array of structure, Passing structure to function, Passing array of structure to function, Structure within structure ( Nested Structure), Union, Pointer to structure
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
About Cache Memory
working of cache memory
levels of cache memory
mapping techniques for cache memory
1. direct mapping techniques
2. Fully associative mapping techniques
3. set associative mapping techniques
Cache memroy organization
cache coherency
every thing in detail
This presentation describes about the various memory allocation methods like first fit, best fit and worst fit in memory management and also about fragmentation problem and solution for the problem.
Interrupt is a process that holds the microprocessor for a while and decide what will be next job that will done by the microprocesssor. Interrupt types ,SIM ,RIM ,DMA ,Maskable interrupt ,Non-Maskable interrupt,Trap,RST and many more has been discussed on this powerpoint . You will be able to know each of the interrupt and their functions from the slides ,some diagram that will help you to develop your knowledge about interrupt . Hardware interrupts are used by devices to communicate that they require attention from the operating system.Hardware interrupts are used by devices to communicate that they require attention from the operating system.Internally, hardware interrupts are implemented using electronic alerting signals that are sent to the processor from an external device, which is either a part of the computer itself, such as a disk controller, or an external peripheral. For example, pressing a key on the keyboard or moving the mouse triggers hardware interrupts that cause the processor to read the keystroke or mouse position.software interrupt is caused either by an exceptional condition in the processor itself, or a special instruction in the instruction set which causes an interrupt when it is executed. The former is often called a trap or exception and is used for errors or events occurring during program execution that are exceptional enough that they cannot be handled within the program itself. For example, a divide-by-zero exception will be thrown if the processor's arithmetic logic unit is commanded to divide a number by zero as this instruction is an error and impossible. The operating system will catch this exception, and can choose to abort the instruction. Software interrupt instructions can function similarly to subroutine calls and are used for a variety of purposes, such as to request services from device drivers, like interrupts sent to and from a disk controller to request reading or writing of data to and from the disk.
About Cache Memory
working of cache memory
levels of cache memory
mapping techniques for cache memory
1. direct mapping techniques
2. Fully associative mapping techniques
3. set associative mapping techniques
Cache memroy organization
cache coherency
every thing in detail
This presentation describes about the various memory allocation methods like first fit, best fit and worst fit in memory management and also about fragmentation problem and solution for the problem.
Interrupt is a process that holds the microprocessor for a while and decide what will be next job that will done by the microprocesssor. Interrupt types ,SIM ,RIM ,DMA ,Maskable interrupt ,Non-Maskable interrupt,Trap,RST and many more has been discussed on this powerpoint . You will be able to know each of the interrupt and their functions from the slides ,some diagram that will help you to develop your knowledge about interrupt . Hardware interrupts are used by devices to communicate that they require attention from the operating system.Hardware interrupts are used by devices to communicate that they require attention from the operating system.Internally, hardware interrupts are implemented using electronic alerting signals that are sent to the processor from an external device, which is either a part of the computer itself, such as a disk controller, or an external peripheral. For example, pressing a key on the keyboard or moving the mouse triggers hardware interrupts that cause the processor to read the keystroke or mouse position.software interrupt is caused either by an exceptional condition in the processor itself, or a special instruction in the instruction set which causes an interrupt when it is executed. The former is often called a trap or exception and is used for errors or events occurring during program execution that are exceptional enough that they cannot be handled within the program itself. For example, a divide-by-zero exception will be thrown if the processor's arithmetic logic unit is commanded to divide a number by zero as this instruction is an error and impossible. The operating system will catch this exception, and can choose to abort the instruction. Software interrupt instructions can function similarly to subroutine calls and are used for a variety of purposes, such as to request services from device drivers, like interrupts sent to and from a disk controller to request reading or writing of data to and from the disk.
At the end of this lecture students should be able to;
Define the C pointers and its usage in computer programming.
Describe pointer declaration and initialization.
Apply C pointers for expressions.
Experiment on pointer operations.
Identify NULL pointer concept.
Experiment on pointer to pointer, pointer arrays, arrays with pointers and functions with pointers.
Apply taught concepts for writing programs.
1. Introduction to Pointers:
- Pointers are variables that store memory addresses. They provide a way to directly manipulate memory, enabling efficient and flexible programming.
2. Pointer to Pointer:
- A pointer that holds the address of another pointer. Useful in scenarios where multiple levels of indirection are required.
3. Null Pointer, Generic Pointer, and Dangling Pointer:
- Discusses the concepts of null pointers (pointers with no valid address), generic pointers (void pointers), and dangling pointers (pointers pointing to released memory).
4. Passing an Array to a Function:
- Explains how to pass arrays to functions, emphasizing the use of pointers to efficiently work with arrays in functions.
5. Returning an Array from Function:
- Explores the technique of returning arrays from functions, often involving the use of pointers to manage memory.
6. Array of Pointers:
- Describes the concept of an array where each element is a pointer, enabling the creation of dynamic data structures.
7. Pointers and 1D Array:
- Examines the relationship between pointers and one-dimensional arrays, highlighting how pointers can be used for array manipulation.
8. Pointers and 2D Array:
- Discusses the use of pointers in managing two-dimensional arrays, which involves handling rows and columns efficiently.
9. Using Pointers for String Manipulation:
- Illustrates how pointers are employed for efficient manipulation of strings, emphasizing dynamic memory allocation for flexible string handling.
10. Two-dimensional Array of Strings:
- Explores the combination of pointers and arrays to handle two-dimensional arrays of strings.
11. Array of Pointers to String:
- Focuses on the concept of an array where each element is a pointer to a string, allowing for dynamic string management.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Biological screening of herbal drugs: Introduction and Need for
Phyto-Pharmacological Screening, New Strategies for evaluating
Natural Products, In vitro evaluation techniques for Antioxidants, Antimicrobial and Anticancer drugs. In vivo evaluation techniques
for Anti-inflammatory, Antiulcer, Anticancer, Wound healing, Antidiabetic, Hepatoprotective, Cardio protective, Diuretics and
Antifertility, Toxicity studies as per OECD guidelines
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Acetabularia Information For Class 9 .docxvaibhavrinwa19
Acetabularia acetabulum is a single-celled green alga that in its vegetative state is morphologically differentiated into a basal rhizoid and an axially elongated stalk, which bears whorls of branching hairs. The single diploid nucleus resides in the rhizoid.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
5. INTRODUCTION:
• Pointers in C are easy and fun to learn.
• Some C programming tasks are performed more easily with
pointers, and other tasks, such as dynamic memory allocation,
cannot be performed without using pointers.
• So it becomes necessary to learn pointers to become a perfect C
programmer.
6. INTRODUCTION:
continue…
• The pointer in C language is a variable which stores the
address of another variable.
• This variable can be of type int, char, array, function, or
any other pointer.
• The size of the pointer depends on the architecture.
However, in 32-bit architecture the size of a pointer is 2
byte.
• As you know, every variable is a memory location and every
memory location has its address defined which can be
accessed using ampersand (&) operator, which denotes an
address in memory.
7. Example:
#include <stdio.h>
int main ()
{
int var1;
char var2[10];
printf("Address of var1 variable: %xn", &var1 );
printf("Address of var2 variable: %xn", &var2 );
return 0; }
8. Definition,Declaration,Initialization,
Dereferencing of pointers.
• Definition of pointers:
• A pointer is a variable whose value is the address of another
variable, i.e., direct address of the memory location. Like any
variable or constant, you must declare a pointer before using it
to store any variable address.
• Other Definitions:
1.Pointer is a variable that holds memory address.
2.Pointer is a variable which holds the address of another
variable. It contains the memory location of the variable instead
of its content.
9. How to Use Pointers
• There are a few important operations, which we will do with the
help of pointers very frequently.
• (a) We define a pointer variable,
• (b) assign the address of a variable to a pointer and
• (c) finally access the value at the address available in the
pointer variable.
• This is done by using unary operator * that returns the value of
the variable located at the address specified by its operand.
10. Declaration of Pointer
• The pointer in c language can be declared using *
(asterisk symbol). It is also known as indirection
pointer used to dereference a pointer.
1.int *a;//pointer to int
2.char *c;
3.float *d//pointer to float
11. Example 1:
#include<stdio.h>
int main()
{
int number=50;
int *p;
p=&number;//stores the address of number variable
printf("Address of p variable is %x n",p);
// p contains the address of the number therefore printing p gives the address of number
.
printf("Value of p variable is %d n",*p);
//Here we will get the value stored at the address contained by p.
return 0;
}
12. Initialization of Pointers
• When we declare a pointer variable it contains garbage value.
i.e. It may be pointing anywhere in the memory. So we should always
assign an address before using it in the program.
• Pointer initialization is the process of assigning address of a variable
to a pointer variable. Pointer variable can only contain address of the
same data type.
• Syntax:
• <pointer declaration>
• Pointer_name =&variable<address of avariable>
13. Initialization of Pointers-Example
EX1:
Int n,*iptr;
iPtr=&n;
Ex2:
Int a=30,*ptr;
Ptr=&a;
We can also initialize the pointer at the time of declaration.
Ex3:
Int roll=102,*ptr=&roll;
Float sal=5000.00,*fptr=&sal;
14. sizeof() operator in C
• The sizeof() operator is commonly used in C.
• It determines the size of the expression or the data
type specified in the number of char-sized storage
units.
• The sizeof() operator contains a single operand which
can be either an expression or a data typecast where
the cast is data type enclosed within parenthesis.
• The data type cannot only be primitive data types such
as integer or floating data types, but it can also be
pointer data types and compound data types such as
unions and structs.
16. Use of sizeof() operator
• we dynamically allocate the array space by
using sizeof() operator:
• Example:
• int *ptr=malloc(10*sizeof(int));
• We use malloc() function to allocate the memory and
returns the pointer which is pointing to this allocated
memory. The memory space is equal to the number of
bytes occupied by the int data type and multiplied by
10.
17. Dereferencing of Pointers:
• When indirection operator (*) is used with the pointer
variable, then it is known as dereferencing a
pointer.
• When we dereference a pointer, then the value of the
variable pointed by this pointer will be returned.
18. Differencing Pointer or Subtraction of pointer
from another pointer:
• Pointer variable can be subtracted from another pointer variable only
if they point to the elements of the same array.
• Syntax:
• Ptr_variable2-ptr_variable1
19. Why we use dereferencing pointer?
• Dereference a pointer is used because of the
following reasons:
• It can be used to access or manipulate the data stored
at the memory location, which is pointed by the pointer.
• Any operation applied to the dereferenced pointer will
directly affect the value of the variable that it points to.
20. Example: Dereferencing of pointer
#include <stdio.h>
int main()
{
int x=9;
int *ptr;
ptr=&x;
*ptr=8; //*ptr will update the value of x
printf("value of x is : %d", x);
return 0;
}
21. Example 2:
#include <stdio.h>
int main()
{
int a=90;
int *ptr1,*ptr2;
ptr1=&a;
ptr2=&a;
*ptr1=7;
*ptr2=6;
printf("The value of a is : %d",a);
return 0;
}
22. Pointer Arithmetic
• We can perform arithmetic operations on the pointers
like addition, subtraction, etc.
• However, as we know that pointer contains the address,
the result of an arithmetic operation performed on the
pointer will also be a pointer if the other operand is of
type integer.
• In pointer-from-pointer subtraction, the result will be
an integer value.
23. Following arithmetic operations are
possible on the pointer in C language:
• Increment
• Decrement
• Addition
• Subtraction
• Comparison
24. Incrementing Pointer in C
• If we increment a pointer by 1, the pointer will start
pointing to the immediate next location.
• This is somewhat different from the general arithmetic
since the value of the pointer will get increased by the
size of the data type.
• We can traverse an array by using the increment
operation on a pointer which will keep pointing to every
element of the array, perform some operation on that,
and update itself in a loop.
25. The Rule to increment the pointer is
given below:
Syntax:
new_address= current_address + i * size_of(data type)
• Where i is the number by which the pointer get
increased.
• pe to which the pointer is pointing.
26. Example: Incrementing a pointer Variable:
#include<stdio.h>
int main()
{
int number=50;
int *p;//pointer to int
p=&number;//stores the address of number variable
printf("Address of p variable is %u n",p);
p=p+1;
printf("After increment: Address of p variable is %u n",p); // in our cas
e, p will get incremented by 4 bytes.
return 0;
}
27. Traversing an array by using pointer
#include<stdio.h>
#include<stdio.h>
void main ()
{
int arr[5] = {1, 2, 3, 4, 5};
int *p = arr;
int i;
printf("printing array elements...n");
for(i = 0; i< 5; i++)
{
printf("%d ",*(p+i));
}
}
28. Decrementing Pointer in C
• Like increment, we can decrement a pointer variable. If we
decrement a pointer, it will start pointing to the previous
location.
• The formula of decrementing the pointer is given
below:
new_address= current_address - i * size_of(data type)
• 32-bit
• For 32-bit int variable, it will be decremented by 2 bytes.
• 64-bit
• For 64-bit int variable, it will be decremented by 4 bytes.
29. Example: Decrementing of pointer
#include <stdio.h>
void main()
{
int number=50;
int *p;//pointer to int
p=&number;//stores the address of number variable
printf("Address of p variable is %u n",p);
p=p-1;
printf("After decrement: Address of p variable is %u n",p); /
/ P will now point to the immediate previous location.
}
30. C Pointer Addition
• We can add a value to the pointer variable. The formula
of adding value to pointer is given below:
new_address= current_address + (number * size_of(dat
a type))
• 32-bit
• For 32-bit int variable, it will add 2 * number.
• 64-bit
• For 64-bit int variable, it will add 4 * number.
31. C Pointer Addition
#include<stdio.h>
int main()
{
int number=50;
int *p;//pointer to int
p=&number;//stores the address of number variable
printf("Address of p variable is %u n",p);
p=p+3; //adding 3 to pointer variable
printf("After adding 3: Address of p variable is %u n",p);
return 0;
}
32. C Pointer Subtraction
• Like pointer addition, we can subtract a value from the
pointer variable. Subtracting any number from a pointer will
give an address.
• The formula of subtracting value from the pointer
variable is given below:
new_address= current_address -
(number * size_of(data type))
• 32-bit
• For 32-bit int variable, it will subtract 2 * number.
• 64-bit
• For 64-bit int variable, it will subtract 4 * number.
33. Example:
#include<stdio.h>
int main()
{
int number=50;
int *p;//pointer to int
p=&number;//stores the address of number variable
printf("Address of p variable is %u n",p);
p=p-3; //subtracting 3 from pointer variable
printf("After subtracting 3: Address of p variable is %u n",p);
return 0;
}
35. Following operations that can never be
performed on pointers are:
• 1. Addition,Multiplication,Division of two pointers.
• 2.Multiplication between pointer and any number.
• 3.Division of pointer by any number.
• Addition of float or double values to the pointer.
36. Relationship between Arrays and Pointers
• In C language ,there is a very strong relationship between pointers
and arrays .Arrays can created as pointers and vice versa.
• Following are the main points for understanding the relationship of
pointers with arrays:
1.Elements of an array are stored in consecutive memory locations.
2.The name of an array is a constant pointer that points to the first
element of the array. i.e it stores the address of the first element, also
known as the base address of array.
3.According to pointer arithmetic, when a pointer variable is
incremented, it points to the next location of its base type.
37. Example:
• Int arr[5]; 1000 1004 1008 1012 1016----------1020
• Int *ptr1; //normal pointer
• Ptr1=&arr[0];
• Ptr1++;
• Int arr[5];
• Int *ptr2[5];// pointer to array
• Ptr2=&arr;//point to the complete
• Ptr2++;
39. Pointer To Array:
• It is possible to create a pointer that points to a complete array
instead of pointing to the individual element of an array such pointer
is known as pointer to an array.
• NORMAL POINTER
• EX: PROGRAM
• POINTER TO ARRAY
• EX PROGRAM
40. Multiple indirection(Double pointer)
• If you define a pointer to pointer;
• WHAT WILL HAPPEN?
The first pointer is used to store the address of the variable
and second pointer is used to store the address of the first
pointer.
Int x=10; Int *ptr1; ptr1=&x;
int **ptr; Ptr=&ptr1;
Declaration: int **ptr;
41. EXAMPLE:
1.Program to find length of the string.
2.Program to compare strings using pointers.
3.Program to write Function to sort the numbers using pointers.
43. DMA: Dynamic Memory Allocation
• C Dynamic Memory Allocation can be defined as a procedure
in which the size of a data structure (like Array) is changed
during the runtime.
• C provides some functions to achieve these tasks. There are 4
library functions provided by C defined under <stdlib.h> header
file to facilitate dynamic memory allocation in C programming.
They are:
1.malloc()
2.calloc()
3.free()
4.realloc()
44. malloc():
• “malloc” or “memory allocation” method in C is used to
dynamically allocate a single large block of memory with the
specified size.
• It returns a pointer of type void which can be cast into a pointer of
any form. It initializes each block with default garbage value.
• Syntax:
ptr = (cast-type*) malloc(byte-size)
Example: ptr = (int*) malloc(100 * sizeof(int));
Since the size of int is 4 bytes, this statement will allocate 400 bytes of memory. And, the pointer ptr holds the
address of the first byte in the allocated memory.
45. calloc():
• calloc” or “contiguous allocation” method in C is used to
dynamically allocate the specified number of blocks of memory
of the specified type.
• It initializes each block with a default value ‘0’.
Syntax: ptr = (float*) calloc(25, sizeof(float));
• This statement allocates contiguous space in memory for 25
elements each with the size of the float.
46. DMA:EXAMPLE
• #include <stdio.h>#include<stdlib.h>main(){ int i; int
*ptr=(int*)malloc(2*sizeof(int)); //allocate 2 elements
if(ptr==NULL) { printf("memory is not available"); exit(1); }
printf("enter 2 no's:n"); for(i=0;i<2;i++) { scanf("%d",ptr+i); }
ptr=(int*) realloc(ptr,4*sizeof(int)); if(ptr==NULL) {
printf("memory is not available"); exit(1); } printf("enter 2
no's:n"); for(i=2;i<4;i++) //change in the for loop {
scanf("%d",ptr+i); } for(i=0;i<4;i++) //change in the for loop
{ printf("%d",*(ptr+i)); } return 0;
47. free():
• “free” method in C is used to dynamically de-allocate the
memory.
• The memory allocated using functions malloc() and calloc() is
not de-allocated on their own.
• Hence the free() method is used, whenever the dynamic
memory allocation takes place. It helps to reduce wastage of
memory by freeing it.
• Syntax: free(ptr())
48. THINGS TO DO : TO MAKE YOURSELF HAPPY
AND POSITIVE