A pointer is a variable that stores the memory address of another variable. Pointers allow accessing and modifying the data stored at the referenced memory location. Pointers can be declared by specifying the data type followed by an asterisk, and are initialized by assigning the address of a variable to the pointer variable. Pointer variables can be used in expressions and arithmetic and can be passed to functions to modify the referenced data. Arrays can also be accessed and traversed using pointers by treating the array name as a pointer to its first element. Pointers to functions allow functions to be passed as arguments and enables polymorphism.
This Presentation gives you all knowledge about #CPointers, #PointersInC.
The given slides are as follows:
1. Introduction of Pointers.
2. Systems to create a pointer in C.
3. Valid Pointer Examples in C.
4. Graphical representation of address assigning in c using pointer.
5. 1st Sample program of pointers in C.
6. Types of Pointers
7. NULL Pointer in C (Types of Pointer)
8. void Pointer in C (Types of Pointer)
9. Wild Pointer in C (Types of Pointer)
10. Changing value of variable using pointer
11. Update and Access value of variable using pointer in example.
12. Types of format specifies to print address in different format.
13. Advantages of Pointer in C.
14. Disadvantages of Pointer in C.
15. Pointers with Array using Programs. #pointerwitharray
16. Another Example of #pointerwitharray.
17. Relationship Between Arrays and Pointers.
18. Relationship Between Arrays and Pointers explanation with diagram.
19. Pointers and String. #PointersAndString
20. Function with Array Parameters using pointers.
21. Passing Pointers to Function or Pointer argument function. #PointerWithFunction
I prepared this slides for the student of FSC BSC BS Computer Science Students. These Slides are very easy to read and understand the pointer logic used in C++ Programming.
All Topic related to pointer is discussed and examples are given
general use of pointer
what is pointer in c language
uses is pointer in c language
representation of pointer in c language
syantax of pointer in c language
program of pointer in c language
This Presentation gives you all knowledge about #CPointers, #PointersInC.
The given slides are as follows:
1. Introduction of Pointers.
2. Systems to create a pointer in C.
3. Valid Pointer Examples in C.
4. Graphical representation of address assigning in c using pointer.
5. 1st Sample program of pointers in C.
6. Types of Pointers
7. NULL Pointer in C (Types of Pointer)
8. void Pointer in C (Types of Pointer)
9. Wild Pointer in C (Types of Pointer)
10. Changing value of variable using pointer
11. Update and Access value of variable using pointer in example.
12. Types of format specifies to print address in different format.
13. Advantages of Pointer in C.
14. Disadvantages of Pointer in C.
15. Pointers with Array using Programs. #pointerwitharray
16. Another Example of #pointerwitharray.
17. Relationship Between Arrays and Pointers.
18. Relationship Between Arrays and Pointers explanation with diagram.
19. Pointers and String. #PointersAndString
20. Function with Array Parameters using pointers.
21. Passing Pointers to Function or Pointer argument function. #PointerWithFunction
I prepared this slides for the student of FSC BSC BS Computer Science Students. These Slides are very easy to read and understand the pointer logic used in C++ Programming.
All Topic related to pointer is discussed and examples are given
general use of pointer
what is pointer in c language
uses is pointer in c language
representation of pointer in c language
syantax of pointer in c language
program of pointer in c language
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.
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.
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.
Read| The latest issue of The Challenger is here! We are thrilled to announce that our school paper has qualified for the NATIONAL SCHOOLS PRESS CONFERENCE (NSPC) 2024. Thank you for your unwavering support and trust. Dive into the stories that made us stand out!
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxEduSkills OECD
Andreas Schleicher presents at the OECD webinar ‘Digital devices in schools: detrimental distraction or secret to success?’ on 27 May 2024. The presentation was based on findings from PISA 2022 results and the webinar helped launch the PISA in Focus ‘Managing screen time: How to protect and equip students against distraction’ https://www.oecd-ilibrary.org/education/managing-screen-time_7c225af4-en and the OECD Education Policy Perspective ‘Students, digital devices and success’ can be found here - https://oe.cd/il/5yV
2. Pointers
• A pointer is a variable that points to or
references a memory location in which data
is stored.
• Each memory cell in the computer has an
address that can be used to access that
location so a pointer variable points to a
memory location we can access and change
the contents of this memory location via the
pointer.
2
3. Pointers
• Pointer declaration:
• A pointer is a variable that contains the memory location
of another variable.
• The syntax is as shown below.
• Start by specifying the type of data stored in the location
identified by the pointer.
• The asterisk tells the compiler that you are creating a
pointer variable.
• Finally you give the name of the variable.
• type * variable name
• Example:
• int *ptr;
• float *string;
3
4. Pointers
• Address operator:
• Once we declare a pointer variable we must
point it to something we can do this by assigning
to the pointer the address of the variable you
want to point as in the following example:
• ptr=#
• This places the address where num is stores into
the variable ptr.
• If num is stored in memory 21260 address then
the variable ptr has the value 21260.
4
5. Pointers
•
•
•
•
•
•
•
•
•
•
•
/* A program to illustrate pointer declaration*/
#include<stdio.h>
main()
{
int *ptr;
int sum;
sum=45;
ptr=∑
printf("n Sum is %d",sum);
printf("n The sum pointer is %u", ptr);
}
5
6. Pointers
int i1;
int i2;
int *ptr1;
int *ptr2;
0x1014
…
0x1010
ptr2:
i1 = 1;
i2 = 2;
0x100C
…
0x1008
ptr1:
ptr1 = &i1;
ptr2 = ptr1;
0x1004
i2:
2
3
0x1000
i1:
3
1
0x1000
0x1000
*ptr1 = 3;
i2 = *ptr2;
Cox & Ng
Arrays and Pointers
6
7. Pointers
• Pointer expressions & pointer arithmetic:
• Like other variables pointer variables can be used in expressions.
• For example if p1 and p2 are properly declared and initialized
pointers, then the following statements are valid.
• y=*p1**p2;
• sum=sum+*p1;
• z= 5* - *p2/p1;
• *p2= *p2 + 10;
• C allows to add integers to or subtract integers from pointers as
well as to subtract one pointer from the other.
• We can also use short hand operators with the pointers
• p1+=; sum+=*p2; etc.,
• we can also compare pointers by using relational operators the
expressions such as p1 >p2 , p1==p2 and p1!=p2 are allowed.
7
8. Pointers
•
•
•
•
•
•
•
•
•
•
•
•
•
•
/*Program to illustrate the pointer expression and pointer arithmetic*/
#include<stdio.h>
main()
{
int *ptr1,*ptr2;
int a,b,x,y,z;
a=30;b=6;
ptr1=&a;
ptr2=&b;
x=*ptr1+ *ptr2- 6;
y=6*- *ptr1/ *ptr2 +30;
printf("na=%d, b=%d",a,b);
printf("nx=%d,y=%d",x,y);
}
8
9. Pointers
•
•
•
•
•
Pointers and function:
1. Call by reference
2. Call by value.
Call by Reference:
When we pass address to a function the
parameters receiving the address should be
pointers. The process of calling a function by
using pointers to pass the address of the
variable is known as call by reference. The
function which is called by reference can change
the values of the variable used in the call.
9
10. Pointers
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
/* example of call by reference*/
#include<stdio.h>
void main()
{
void fncn(int *,int *);
int a=20,b=30;
printf("n Value of a and b before function call =%d %d",a,b);
fncn(&a,&b);
printf("n Value of a and b after function call =%d %d",a,b);
}
void fncn(int *p,int *q)
{
*p=100;
*q=200;
}
10
11. Pointers
• Pointer to arrays:
• An array is actually very much like pointer.
• We can declare the arrays first element as a[0]
or as int *a because a[0] is an address and *a is
also an address the form of declaration is
equivalent.
• The difference is pointer is a variable and can
appear on the left of the assignment operator
that is lvalue.
• The array name is constant and cannot appear
as the left side of assignment operator.
11
12. Pointers
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
/* A program to display the contents of array using pointer*/
#include<stdio.h>
main()
{
int a[100];
int i,j,n,*ptr;
printf("nEnter the elements of the arrayn");
scanf("%d",&n);
printf("Enter the array elements");
for(i=0;i< n;i++)
{
scanf("%d",&a[i]);
}
printf("Array element are");
for(ptr=a;ptr<(a+n);ptr++)
{
printf("nValue of stored at address %u",ptr);
}
}
12
13. Pointers
•
•
•
•
•
•
•
•
•
•
•
Multi-Dimensional Arrays
int multi[ROWS][COLS];
we can access individual elements of the array multi using either:
multi[row][col]
or
*(*(multi + row) + col)
To understand more fully what is going on, let us replace
*(multi + row)
with X as in:
*(X + col)
Now, from this we see that X is like a pointer since the expression is
de-referenced and we know that col is an integer. The arithmetic being used here
is of a special kind called "pointer arithmetic". That means that, since we are
talking about an integer array, the address pointed to by (i.e. value of) X + col + 1
must be greater than the address X + col by and amount equal to sizeof(int).
13
14. Pointers
• Since we know the memory layout for 2 dimensional
arrays, we can determine that in the expression multi +
row as used above, multi + row + 1 must increase by value
an amount equal to that needed to "point to" the next
row, which in this case would be an amount equal to COLS
* sizeof(int).
• That says that if the expression *(*(multi + row) + col) is to
be evaluated correctly at run time, the compiler must
generate code which takes into consideration the value of
COLS, i.e. the 2nd dimension. Because of the equivalence
of the two forms of expression, this is true whether we
are using the pointer expression as here or the array
expression multi[row][col].
14
15. Pointers
• Thus, to evaluate either expression, a total of 5 values must be
known:
• The address of the first element of the array, which is returned by
the expression multi, i.e., the name of the array.
• The size of the type of the elements of the array, in this case
sizeof(int).
• The 2nd dimension of the array
• The specific index value for the first dimension, row in this case.
• The specific index value for the second dimension, col in this case.
• Given all of that, consider the problem of designing a function to
manipulate the element values of a previously declared array. For
example, one which would set all the elements of the array multi
to the value 1.
15
16. Pointers
•
More on Strings
•
Well, we have progressed quite a way in a short time! Let's back up a little and look at what was done in Chapter
3 on copying of strings but in a different light. Consider the following function:
char *my_strcpy(char dest[], char source[])
{
int i = 0;
while (source[i] != '')
{
dest[i] = source[i];
i++;
}
dest[i] = '';
return dest;
}
•
•
•
•
•
•
•
•
•
•
•
•
Recall that strings are arrays of characters. Here we have chosen to use array notation instead of pointer
notation to do the actual copying. The results are the same, i.e. the string gets copied using this notation just as
accurately as it did before. This raises some interesting points which we will discuss.
•
Since parameters are passed by value, in both the passing of a character pointer or the name of the array as
above, what actually gets passed is the address of the first element of each array. Thus, the numerical value of
the parameter passed is the same whether we use a character pointer or an array name as a parameter. This
would tend to imply that somehow source[i] is the same as *(p+i).
16
17. Pointers
•
Pointers to Functions
•
Up to this point we have been discussing pointers to data objects. C also permits
the declaration of pointers to functions. Pointers to functions have a variety of
uses and some of them will be discussed here.
•
Consider the following real problem. You want to write a function that is capable
of sorting virtually any collection of data that can be stored in an array. This
might be an array of strings, or integers, or floats, or even structures. The sorting
algorithm can be the same for all. For example, it could be a simple bubble sort
algorithm, or the more complex shell or quick sort algorithm. We'll use a simple
bubble sort for demonstration purposes.
•
Sedgewick [1] has described the bubble sort using C code by setting up a function
which when passed a pointer to the array would sort it. If we call that function
bubble(), a sort program is described by bubble_1.c, which follow
17
18. Pointers
•
/* Program bubble_3.c from PTRTUT10.HTM 6/13/97 */
•
#include <stdio.h>
•
int arr[10] = { 3,6,1,2,3,8,4,1,7,2};
•
•
void bubble(int *p, int N);
int compare(int *m, int *n);
•
•
•
•
•
int main(void)
{
int i;
putchar('
');
•
•
•
•
•
•
•
for (i = 0; i < 10; i++)
{
printf("%d ", arr[i]);
}
bubble(arr,10);
putchar('
');
•
•
•
•
•
•
}
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
•
void bubble(int *p, int N)
{
int i, j, t;
for (i = N-1; i >= 0; i--)
{
for (j = 1; j <= i; j++)
{
if (compare(&p[j-1], &p[j]))
{
t = p[j-1];
p[j-1] = p[j];
p[j] = t;
}
}
}
}
for (i = 0; i < 10; i++)
{
printf("%d ", arr[i]);
}
return 0;
18
20. Pointers
•
Here 6024, 8085, 9091 is any arbitrary address, it may be different.
•
Value of k is content of k in memory which is 8085
•
Value of *k means content of memory location which address k keeps.
•
•
•
•
•
•
•
•
•
•
k keeps address 8085 .
Content of at memory location 8085 is 6024
In the same way **k will equal to 3.
Short cut way to calculate:
Rule: * and & always cancel to each other
i.e. *&a = a
So *k = *(&j) since k = &j
*&j = j = 6024
And
**k = **(&j) = *(*&j) = *j = *(&i) = *&i = i = 3
20