Pointer variables contain memory addresses that point to other variables in memory. A pointer contains the address of another variable. Pointers provide indirect access to data in memory. Pointer variables must be declared with a data type and the * symbol indicates it is a pointer. The & operator returns the memory address of a variable and * dereferences a pointer to access the value at that memory address. Pointers can be assigned, compared, and perform arithmetic operations like incrementing to point to the next memory location.
Computers use their memory for storing instructions of the programs and the values of the variables. Memory is a sequential collection of storage cells. Each cell has an address associated with it. Whenever we declare a variable, the system allocates, somewhere in the memory, a memory location and a unique address is assigned to this location.c pointers lecture
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.
Computers use their memory for storing instructions of the programs and the values of the variables. Memory is a sequential collection of storage cells. Each cell has an address associated with it. Whenever we declare a variable, the system allocates, somewhere in the memory, a memory location and a unique address is assigned to this location.c pointers lecture
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.
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
Cyber security refers to every aspect of protecting an organization and its employees and assets against cyber threats. As cyberattacks become more common and sophisticated and corporate networks grow more complex, a variety of cyber security solutions are required to mitigate corporate cyber risk.
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
Cyber security refers to every aspect of protecting an organization and its employees and assets against cyber threats. As cyberattacks become more common and sophisticated and corporate networks grow more complex, a variety of cyber security solutions are required to mitigate corporate cyber risk.
C Programming Language is the most popular computer language and most used programming language till now. It is very simple and elegant language. This lecture series will give you basic concepts of structured programming language with C.
Water scarcity is the lack of fresh water resources to meet the standard water demand. There are two type of water scarcity. One is physical. The other is economic water scarcity.
Democratizing Fuzzing at Scale by Abhishek Aryaabh.arya
Presented at NUS: Fuzzing and Software Security Summer School 2024
This keynote talks about the democratization of fuzzing at scale, highlighting the collaboration between open source communities, academia, and industry to advance the field of fuzzing. It delves into the history of fuzzing, the development of scalable fuzzing platforms, and the empowerment of community-driven research. The talk will further discuss recent advancements leveraging AI/ML and offer insights into the future evolution of the fuzzing landscape.
Vaccine management system project report documentation..pdfKamal Acharya
The Division of Vaccine and Immunization is facing increasing difficulty monitoring vaccines and other commodities distribution once they have been distributed from the national stores. With the introduction of new vaccines, more challenges have been anticipated with this additions posing serious threat to the already over strained vaccine supply chain system in Kenya.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
Automobile Management System Project Report.pdfKamal Acharya
The proposed project is developed to manage the automobile in the automobile dealer company. The main module in this project is login, automobile management, customer management, sales, complaints and reports. The first module is the login. The automobile showroom owner should login to the project for usage. The username and password are verified and if it is correct, next form opens. If the username and password are not correct, it shows the error message.
When a customer search for a automobile, if the automobile is available, they will be taken to a page that shows the details of the automobile including automobile name, automobile ID, quantity, price etc. “Automobile Management System” is useful for maintaining automobiles, customers effectively and hence helps for establishing good relation between customer and automobile organization. It contains various customized modules for effectively maintaining automobiles and stock information accurately and safely.
When the automobile is sold to the customer, stock will be reduced automatically. When a new purchase is made, stock will be increased automatically. While selecting automobiles for sale, the proposed software will automatically check for total number of available stock of that particular item, if the total stock of that particular item is less than 5, software will notify the user to purchase the particular item.
Also when the user tries to sale items which are not in stock, the system will prompt the user that the stock is not enough. Customers of this system can search for a automobile; can purchase a automobile easily by selecting fast. On the other hand the stock of automobiles can be maintained perfectly by the automobile shop manager overcoming the drawbacks of existing system.
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdffxintegritypublishin
Advancements in technology unveil a myriad of electrical and electronic breakthroughs geared towards efficiently harnessing limited resources to meet human energy demands. The optimization of hybrid solar PV panels and pumped hydro energy supply systems plays a pivotal role in utilizing natural resources effectively. This initiative not only benefits humanity but also fosters environmental sustainability. The study investigated the design optimization of these hybrid systems, focusing on understanding solar radiation patterns, identifying geographical influences on solar radiation, formulating a mathematical model for system optimization, and determining the optimal configuration of PV panels and pumped hydro storage. Through a comparative analysis approach and eight weeks of data collection, the study addressed key research questions related to solar radiation patterns and optimal system design. The findings highlighted regions with heightened solar radiation levels, showcasing substantial potential for power generation and emphasizing the system's efficiency. Optimizing system design significantly boosted power generation, promoted renewable energy utilization, and enhanced energy storage capacity. The study underscored the benefits of optimizing hybrid solar PV panels and pumped hydro energy supply systems for sustainable energy usage. Optimizing the design of solar PV panels and pumped hydro energy supply systems as examined across diverse climatic conditions in a developing country, not only enhances power generation but also improves the integration of renewable energy sources and boosts energy storage capacities, particularly beneficial for less economically prosperous regions. Additionally, the study provides valuable insights for advancing energy research in economically viable areas. Recommendations included conducting site-specific assessments, utilizing advanced modeling tools, implementing regular maintenance protocols, and enhancing communication among system components.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
1. Gandhinagar institute of technology
subject : CPU(2110003)
Topic Name:
Branch : computer
Batch : CE
Name : Vardhil Patel
Guided By: Prof. __________
Pointer
2. Pointers
A pointer is a variable that holds a memory
address.
This address is the location of another object in
memory.
For example, if one variable contains the address of
another variable, the first variable is said to point to
the second.
Basically, a pointer contains an address of another
variable.
Pointers provide an indirect means of accessing or
retrieving the data from memory.
4. The ‘&’ and ‘*’
Consider the declaration int ab=3;
This declaration tells the compiler
a) Reserve space in memory to hold the
integer value.
b) Associate the name ab with this memory
location.
c) Store the value 3 at this location.
5. The ‘&’ and ‘*’
ab
3
Location name
Value at Location
1000 Address
6. Declaring pointer
Data-type *name;
* is a unary operator, also called as indirection
operator.
Data-type is the type of object which the pointer is
pointing.
Any type of pointer can point to anywhere in the
memory.
* is used to declare a pointer and also to dereference a
pointer.
7. When you write int *,
compiler assumes that any address that it holds
points to an integer type.
m= &count;
it means memory address of count variable is stored
into m.
& is unary operator that returns the memory address.
i.e. & (orally called as ampersand) is returning the
address.
so it means m receives the address of count.
8. Suppose, count uses memory
Address 2000 to store its value 100.
so, m=&count means m has 2000
address.
q= *m
it returns the value at address m.
value at address 2000 is 100.
so, q will return value 100.
i.e. q receives the value at address m.
count=1002000
9. In C every variable must be declared for its data type.
Since pointer variables contain addresses that belong to
a separate data type they must be declared as pointers.
The declaration of pointer variable takes following form:
this tells the compile there things about the variable
pt_name
1. The asterisk(*) tell that the variable pt_name is a pointer
variable
2. pt_name needs a memory location.
3. pt_name points to a variable of type data_type.
For example:-int *q;
here q is pointer variable that can hold the address
data_type *variable_name;
10. The ‘&’ and ‘*’
‘&’ Address of operator
‘*’ Value at address operator. Also called the Indirection
Operator.
‘&a’ Returns the address of variable a.
‘*a’ Returns the value stored in a particular
address.
13. Initializing Pointer
Address of some variable can be assigned to a pointer
variable at the time of declaration of the pointer
variable.
For ex:
int num; int num;
int *ptr=# int *p;
p=#
These two statements above are equivalent to
following statements.
4/25/2017 Ashim Lamichhane 13
14. 1/14/10
NULL
• NULL is a special value which may be assigned to a pointer
• NULL indicates that this pointer does not point to any variable
(there is no pointee)
• Often used when pointers are declared
int *pInt = NULL;
• Often used as the return type of functions that return a pointer to
indicate function failure
int *myPtr;
myPtr = myFunction( );
if (myPtr == NULL){
/* something bad happened */
}
• Dereferencing a pointer whose value is NULL will result in
program termination.
17. 17
Pointer Assignments
Since, the variable j is containing an address, it is
declared as int *j;
This declaration tells the compiler that j will be used to
store the address of an integer value – i.e j points to an
integer.
18. 18
An Example:Pointer Assignments
main()
{
int j=3;
int *k;
k = &j;
printf(“Address of j=%d”,&j);
printf(“Address of j=%d”,k);
printf(“Address of j=%d”,&k);
printf(“Value of k=%d”,k);
printf(“Value of j=%d”,j);
printf(“Value of j=%d”,*(&j));
printf(“Value of j=%d”,*j);
}
Output:
Address of j = 1000
Address of j = 1000
Address of k = 2000
Value of k = 1000
Value of j = 3
Value of j = 3
Value of j = error
19. Pointer Arithmetic There are only two arithmetic operations that can be
used on pointers
Addition
Subtraction
To understand this concept, lets p1 be an integer
pointer with value 2000 address.
int is of 2 bytes
After expression p1++;
P1 contains address 2002 not 2001.
20. Each time p1 is incremented, it will point to next
integer.
The same is true for decrement.
for p1--;
Causes value of p1 to be 1998.
Each time a pointer is incremented, it points to the
memory location of the next element of its base type.
If decremented, then it points to previous element
location.
P1=p1+12; makes p1 points to 12th element of p1 type.
21. Arithmetic Rules
You cannot multiply or divide pointers.
You cannot add or subtract two pointers.
You cannot apply bitwise operators to them.
You cannot add or subtract type float or double to or
from pointers.
22. Pointer Comparison
You can compare two pointers in a relational
expression, example:
if(p<q)
printf(“p points to lower memory than q n”);
Pointer comparison are useful only when two pointers
point to a common object such as an array.
23. 23
Pointer Conversions
One type of pointer can be converted to another type of pointer.
Consider the following example:
main()
{
double x = 100.1,y;
int *p;
/*The next statement causes p to point to double*/
p = (int*)&x;
y = *p;
printf(“The value of x is: %f”,y);
}
24. POINTER TO POINTER (Double Pointer)
C allows the use of pointers that point to other
pointers and these in turn, point to data.
For pointers to do that, we only need to add asterisk
(*) for each level of reference. For example:
int a=20;
int *p;
int **q; pointer to “a pointer to
an integer”
p=&a;
q=&p;
• To refer to variable ‘a’ using pointer
‘q’, dereference it once i.e. *p
• To refer to variable ‘a’ using pointer
‘q’, dereference it twice because
there are two levels of indirection
involved.
• Both *p and **q displays 20 if they
are printed with a printf statement.
25.
26. Double Pointer
int main () {
int var;
int *ptr;
int **pptr;
var = 3000;
ptr = &var;
/* take the address of ptr using
address of operator & */
pptr = &ptr;
/* take the value using pptr */
printf("Value of var = %dn", var );
printf("Value available at *ptr =
%dn", *ptr );
printf("Value available at **pptr =
%dn", **pptr);
return 0;
}
OUTPUT
Value of var = 3000
Value available at *ptr = 3000
Value available at **pptr = 3000
27. Array Of Pointers
An array of pointers can be declared as
data_type *pointer_name[size];
For ex:
int *p[10];
This declares an array of 10 pointers, each of which points to an integer.
The first pointer is called p[0], the second is p[1] and so on up to p[9].
Initially, these pointers are uninitialized and they can be used as below.
int a=10, b=100, c=1000;
p[0]=&a;
p[1]=&b;
p[2]=&c; and so on.
28. Relationship between 1-D array and pointer
Array name by itself is an address or pointer.
It points to the address of the first element(0th element
of an array)
If x is 1D array, the address of the first element can be
expressed as &x[0] or as x.
Similarly address of second array element can be
written as &x[1]or x+1.
In general, address on an array element i can be
expressed as &x[i] or x+i
29. • In general address of array element i can be
expressed as &x[i] or x+i
• x[i] and *(x+i) both represents represents the
content of the address.
Array x
Address of
first
array
element
can be
expressed as
&x[0] or
simply x
x[0] x[1] x[2] x[3]
Array x
Address of
second
array
element
can be
expressed as
&x[1] or
simply x+1
x[0] x[1] x[2] x[3]
30. #include <stdio.h>
int main(){
int x[5]={20,40,60,80,100},k;
printf("narray element ttelements value
ttaddressn");
for(k=0;k<5;k++){
printf("x[%d]ttt%dttt%pn",k,*(x+k),x+k );
}
}
array
element
elements
value
address
x[0] 20 0x7fff5bb0
bbb0
x[1] 40 0x7fff5bb0
bbb4
x[2] 60 0x7fff5bb0
bbb8
x[3] 80 0x7fff5bb0
bbbc
x[4] 100 0x7fff5bb0
bbc0
To display array element with their address using array name as a pointer
OUTPUT
• Element k acts as the element number( 0,1,2,3,4)
• x acting array is added with k i.e k is added with the address of first
element, it points to the consecutive memory location.
• Thus &x[k] is same as *(x+k)
31. /* WAP to calculate average marks of 10 students in a subject
using pointer*/
#include <stdio.h>
int main(void){
float marks[10],sum=0;
int i;
float avg;
printf("Enter marks of 10 students: ");
for(i=0;i<10;i++){
scanf("%f",marks+i);
sum+=*(marks+i);
}
avg=sum/10;
printf("nThe average is=%fn", avg);
}
4/25/2017 Ashim Lamichhane 31
mark
s+0
mark
s+1
mark
s+2
mark
s+3
mark
s+4
32. Pointers and 2-D Arrays
A two dimensional array is actually a collection of one
dimensional arrays, each indicating a row (i.e. 2-D array can be
thought as one dimensional array of rows).
It is stored in memory in the row form. For ex.
1 2 3
4 5 6
7 8 9
• Is stored in the row major order in memory as illustrated
below
1 2 3 4 5 6 7 8 9
a[0][0] a[0][1] a[0][2] a[1][1] a[1][2] a[2][0] a[2][1] a[2][2]
65500 65502 65504 65506 65508 65510 65512 65514 65516
a=
33. Syntax for declaration of 2-D array
data_type (*ptr_var)[size2];
Instead of data_type array[size1][size2];
Ex: Suppose x is a two dimensional integer array having 4 rows
and 5 columns. We declare x as
int (*x)[5];
rather than
int x[4][5];
x points to the first 5 element array, which is actually first row of
the two dimensional array.
Similarly x+1 points to the second 5 element array, which is the
second row of the two dimensional array
34. Passing Pointer to a Function
A pointer can be passed to a function as an argument.
Passing a pointer means passing address of a variable
instead of value of the variable.
As address is passed in this case, this mechanism is also
known as call by address or call by reference.
As address of variable is passed in this mechanism, if
value in the passed address is changed within function
definition, the value of actual variable is also changed.
35. #include <stdio.h>
void conversion(char *);
int main(){
char input;
printf("Enter character of your
choice: ");
scanf("%c",&input);
conversion(&input);
printf("The corresponding
character is: %cn",input );
}
void conversion(char *c){
if (*c>=97 && *c<=122)
{
*c=*c-32;
}
else if(*c >=65 && *c<=90){
*c=*c+32;
}
}
Output
Enter Character of Your
Choice: a
The corresponding Char is:
A
Enter Character of Your
Choice: b
The corresponding Char is:
B
36. String And Pointer
As strings are arrays and arrays are closely connected with
pointers, we can say that string and pointers are closely
related.
char name[5]=“shyam”;
As the string variable name is an array of characters, it is a
pointer to the first character of the string and can be used
to access and manipulate the characters of the string.
When a pointer to char is printed in the format of a string, it
will start to print the pointer character and then successive
characters until the end of string is reached.
Thus name prints “shyam”, name+1 prints “hyam”, name+2
prints “yam” and so on.