The document discusses pointers in C programming. It provides examples of declaring and using pointers, dereferencing pointers, pointer arithmetic, passing pointers to functions, and const pointers. The examples demonstrate how to print values at addresses, increment pointers, pass pointers to functions to modify variables, and common string functions using pointers.
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.
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.
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.
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.
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.
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.
The ppt describes usage of functions in c language. Showing basic use of function and determining the differences between function call by value and function call by reference using pointer. It also includes valid use in swapping two numbers in c along with different outputs. Overall its a basic note for c language.
Function is a set of statement which is designed to perform some specific task. Function gives functionality to programmer to use one module(task) for more times rather then write same code again and again....
Content:
What is function pointer?
Motivation, what is the use cases of function pointer?
Declaration of function pointer in c
Initialization of function pointer in c
Calling a function using the function pointer
Example on function pointer
Function pointer as arguments
By:
AbuBakr Mohammed Ramadan
#AbuBakrMR
Note: This slide was created by me. I am Md. Touhidul Islam Shawan. Here in these slide I have written about some basic points of function of c program and how the function works.
This presentation covers very frequently used standard library functions also called as inbuilt functions. a brief description about function and its declaration (syntax) is defined for help.
hey this is Rupendra choudhary..!! i shared my "c" lang ppt..!!! u just goto that ppt if u r in deep with "c" ..!!! i create after i hv played a much with "c"..(sorry bt ppt is slightly disturbd may be due to unsupportable msppt2010 by slideshare)...find me on rupendrachoudhary1990@gmail.com or https://rupendrachoudhary.wordpress.com
The ppt describes usage of functions in c language. Showing basic use of function and determining the differences between function call by value and function call by reference using pointer. It also includes valid use in swapping two numbers in c along with different outputs. Overall its a basic note for c language.
Function is a set of statement which is designed to perform some specific task. Function gives functionality to programmer to use one module(task) for more times rather then write same code again and again....
Content:
What is function pointer?
Motivation, what is the use cases of function pointer?
Declaration of function pointer in c
Initialization of function pointer in c
Calling a function using the function pointer
Example on function pointer
Function pointer as arguments
By:
AbuBakr Mohammed Ramadan
#AbuBakrMR
Note: This slide was created by me. I am Md. Touhidul Islam Shawan. Here in these slide I have written about some basic points of function of c program and how the function works.
This presentation covers very frequently used standard library functions also called as inbuilt functions. a brief description about function and its declaration (syntax) is defined for help.
hey this is Rupendra choudhary..!! i shared my "c" lang ppt..!!! u just goto that ppt if u r in deep with "c" ..!!! i create after i hv played a much with "c"..(sorry bt ppt is slightly disturbd may be due to unsupportable msppt2010 by slideshare)...find me on rupendrachoudhary1990@gmail.com or https://rupendrachoudhary.wordpress.com
This document contains some programs of C using Data structures, like Stack, LinkedList, queue, Fibonacci series, addition and multiplication of two matrices,etc.
This presentation explains about operator overloading in C++.
It explains how to overload using member functions and friend functions. It discusses about the operators which can be overloaded only using member function and the operators which cannot be overloaded.
https://youtu.be/cSH1dm9dXHM
This video explains about Range based for loop which can be used to traverse the elements of any container.
It demonstrates with primitive arrays, vectors and list.
Capture the traversed elements by value and by reference.
It also demonstrates using auto to simplify the declarations.
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
How to Create Map Views in the Odoo 17 ERPCeline George
The map views are useful for providing a geographical representation of data. They allow users to visualize and analyze the data in a more intuitive manner.
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
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
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.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
2. int main( )
{
int x = 10;
printf(“x = %d “ , x); //Prints the value of x.
printf(“&x = %p “ , &x);
}
mohammed.sikander@cranessoftware.com 2
& operator gets the address of variable.
%p is the correct format specifier to print address.
3. 1. int main( )
2. {
3. int x = 10;
4. printf(“x = %d n“ , x); //Prints the value of x.
5. printf(“&x = %p n“ , &x);
6. int *ptr; //Declaration of pointer
7. ptr = &x;
8. printf(“ptr = %p n” , ptr);
9. printf(“*ptr = %d n” , *ptr);
10. }
mohammed.sikander@cranessoftware.com 3
6. * is used to declare a pointer
9. * is used to get value at address (dereference)
4. 1. int main( )
2. {
3. int x = 5, y = 8;
4. int *p1 , p2;
5. p1 = &x;
6. p2 = &y;
7. printf(“ *p1 = %d “ , *p1);
8. printf(“ *p2 = %d “ , *p2);
9. }
mohammed.sikander@cranessoftware.com 4
6. Pointer size is same irrespective of type.
Pointers are like shorcuts to files (in windows).
A size of shortcut to a 1MB file, 1GB file ,
200MB file is same
mohammed.sikander@cranessoftware.com 6
9. int main( )
{
int x;
printf(“ x = %d “ , x); //garbage value.
int *ptr;
printf(“ ptr = %p “ , ptr); //garbage address.
printf(“ *ptr = %d “ ,*ptr);
}
mohammed.sikander@cranessoftware.com 9
10. int main( )
{
int *ptr1; // unitialized pointer
int *ptr2 = NULL; // NULL pointer
if(ptr2 != NULL) // Can be safeguarded
printf(“ *ptr2 = %d n”, *ptr2);
if(ptr1 != NULL) // Cannot be safeguarded
printf(“ *ptr1 = %d n”, *ptr1);
}
mohammed.sikander@cranessoftware.com 10
11. void update(int x)
{
x = x + 5;
printf(“Update x = %d “ , x);
}
int main( )
{
int x = 2;
update( x );
printf(“Main x = %d “ , x);
}
mohammed.sikander@cranessoftware.com 11
12. void update(int *px)
{
*px = *px + 5;
printf(“Update *px = %d “ , *px);
}
int main( )
{
int x = 2;
update( &x );
printf(“Main x = %d “ , x);
}
mohammed.sikander@cranessoftware.com 12
15. a = 3 , b = 7
a = a + b; //10
b = a – b; //3
a = a – b; //7
mohammed.sikander@cranessoftware.com 15
a = 7 , b = 10
a = a * b; //70
b = a / b; //7
a = a / b; //10
a = 5 , b = 10
a = a ^ b; //
b = a ^ b; //5
a = a ^ b; //10
16. int main( )
{
int arr[ ] = {12,23,34,54};
printf(“ %p “ , &arr[0]);
printf(“ %p “ , arr);
}
mohammed.sikander@cranessoftware.com 16
Array name gives the base address (address of first
element of array )
17. int main( )
{
int arr[ ] = {12,23,34,54};
int *p1 = &arr[0];
int *p2 = arr;
printf(“ %d “ , *p1);
printf(“ %d “ , *p2);
}
mohammed.sikander@cranessoftware.com 17
18. The following arithmetic operations with pointers are legal:
• add an integer to a pointer (+ and +=)
• subtract an integer from a pointer(- and -=).
• use a pointer as an operand to the ++ and -- operators.
• subtract one pointer from another pointer, if they point
to objects of the same type.
• compare two pointers
• Operations meaningless unless performed on an array
• All other arithmetic operations with pointers are illegal.
19. Ptr = ptr + int
When you add or subtract an integer to or from a
pointer, the compiler automatically scales the
integer to the pointer's type. In this way, the integer
always represents the number of objects to jump,
not the number of bytes.
int x; // Assume address of x is 1000
int *ptr = &x; // ptr = 1000
ptr = ptr +1; // ptr-> 1004 and not 1001
31. Constant Pointer : Pointer is fixed to one
location.
Pointer to const : Pointer has read-only
access.
mohammed.sikander@cranessoftware.com 31
int * const cp;
const int * pc;
Constant pointer should be initialized.
32. int main( )
{
int x = 10 ;
const int y = 20;
const int * pc1 ;
pc1 = &x;
pc1 = &y;
}
mohammed.sikander@cranessoftware.com 32
int main( )
{
int x = 10 ;
const int y = 20;
int * const cp1;
int * const cp2 = &x;
int * const cp3 = &y;
const int * const cp4 = &y;
cp2 = &y;
}
#include <stdio.h>
int main( )
{
char c , *pc;
short int si , *psi;
int i , *pi;
double d , *pd;
printf(" c %d pc %d \n" , sizeof(c) , sizeof(pc));
printf(" si %d psi %d \n" , sizeof(si) , sizeof(psi));
printf(" i %d pi %d \n" , sizeof(i) , sizeof(pi));
printf(" d %d pd %d \n" , sizeof(d) , sizeof(pd));
return 0;
}
Use typecasting to remove warnings
#include <stdio.h>
void swap( int *pa , int *pb)
{
int temp = *pa;
*pa = *pb;
*pb = temp;
printf(" *pa = %d *pb = %d \n" ,*pa , *pb);
}
int main( )
{
int a = 5 , b = 10;
swap( &a , &b );
printf("a = %d b = %d \n" , a , b);
}
#include <stdio.h>
void swap( int *pa , int *pb)
{
int *temp = pa;
pa = pb;
pb = temp;
printf(" *pa = %d *pb = %d \n" ,*pa , *pb);
}
int main( )
{
int a = 5 , b = 10;
swap( &a , &b );
printf("a = %d b = %d \n" , a , b);
}