0% found this document useful (0 votes)
69 views6 pages

Understanding Pointers in C Programming

This document provides an overview of pointers in C programming. It defines a pointer as a variable that stores the memory address of another variable. Pointers are important in C as they allow for direct memory manipulation, which can improve performance and reduce code complexity. The document discusses pointer declaration syntax, different pointer types, advantages of using pointers, and provides examples of pointer code for adding two numbers and finding the maximum of two numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
69 views6 pages

Understanding Pointers in C Programming

This document provides an overview of pointers in C programming. It defines a pointer as a variable that stores the memory address of another variable. Pointers are important in C as they allow for direct memory manipulation, which can improve performance and reduce code complexity. The document discusses pointer declaration syntax, different pointer types, advantages of using pointers, and provides examples of pointer code for adding two numbers and finding the maximum of two numbers.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 6

PRESENTATION ABOUT POINTER IN C PROGRAMMING

 GROUP [6] MEMBERS


1. 24724 MAHORO Charity
2. 24757 MANZI Theogen
3. 23383 Vital GATERA KALINGANIRE
4. 25127 ISHIMWE Clemence
5. 21493 BIZIMANA Moise
6. 24711 KAMALI Olivier
7. 24571 KAYONGA Axel
8. 24473 MANZI Boris
9. 24408 RUTAGWERA SHEMA Ivan
POINTERS

 POINTER : this is a variable that stores the memory address of another variable as its
value .the pointer variable points to a data type(like int )of the same type, and is created
with *operator .
Pointer variable points to a data type (like int ) of the same type, and is created with
the * operator. The address of the variable you are working with is assigned to the pointer.
 Why should we learn About Pointers in c programming?
Pointer are important in C programming because they give you the ability to manipulate the
data in the computer's memory this can reduce the code and improve the performance. 
Syntax:
datatype *var_name;

How to declare pointer variables?

There are so many ways you can declare a pointer variables.

Syntax:
Datatype * var_name;
 int* myAge;
 int *myAge;

Types of pointers
 Null pointer
 Void pointer
 Wild pointer
 Dangling pointer
Advantages of pointers in c programming
 Pointers provide direct access to memory
 Pointers reduce the execution time of programs
 Pointers reduce the storage space and complexity of programs
 Pointers allow us to perform dynamic memory allocation and deallocation
Examples of c programs of pointers
1st example :
#include<stdio.h>
main()
{
int myAge=20; //an int variable
int *ptr=&myAge;

printf("%d\n",myAge); //output the value of myAge(20)

printf("%d\n",&myAge); //output the memory address of myAge

printf("%d\n",ptr); //output the memory address of myAge with the pointer


}
Pointer Program to add two numbers using pointers.

2nd example:
int main(){
int fno, sno, *ptr, *qtr, sum;
printf("\n\n Pointer : Add two numbers :\n");
printf("--------------------------------\n");
printf(" Input the first number : ");
scanf("%d", &fno);
printf(" Input the second number : ");
scanf("%d", &sno);
ptr = &fno;
qtr = &sno;
sum = *ptr + *qtr;
printf(" The sum of the entered numbers is : %d\n\n",sum);
return 0;
}
find the maximum number between two numbers using a pointer?
#include <stdio.h>

int main(){

int fno,sno,*ptr1=&fno,*ptr2=&sno;

printf("\n\n Pointer : Find the maximum number between two numbers :\n");

printf("------------------------------------------------------------\n");

printf(" Input the first number : ");

scanf("%d", ptr1);

printf(" Input the second number : ");

scanf("%d", ptr2);

if(*ptr1>*ptr2)

printf("\n\n %d is the maximum number.\n\n",*ptr1);

else

printf("\n\n %d is the maximum number.\n\n",*ptr2);

You might also like