SlideShare a Scribd company logo
C Programming - Pointers

Organized By: Vinay Arora
               Assistant Professor, CSED
               Thapar University, Patiala
Program - 1
 #include<stdio.h>                                   void swapr(int x, int y)
 #include<conio.h>                                    {
 void swapr(int,int);                                  int t;
 int main()                                            t=x;
  {                                                    x=y;
   int a=10,b=20;                                      y=t;
   clrscr();                                          }

  printf("Value of variable a=%d and b=%d",a,b);
  swapr(a,b);
  printf("nValue of variable a=%d and b=%d",a,b);

   getch();
  }




                                    Vinay Arora
                                       CSED
Program – 1 (output)




                Vinay Arora
                   CSED
Program - 2
 #include<stdio.h>                                   void swapr(int *x, int *y)
 #include<conio.h>                                    {
 void swapr(int *, int *);                             int t;
 int main()                                            t=*x;
  {                                                    *x=*y;
   int a=10,b=20;                                      *y=t;
   clrscr();                                          }

  printf("Value of variable a=%d and b=%d",a,b);
  swapr(&a,&b);
  printf("nValue of variable a=%d and b=%d",a,b);

   getch();
  }



                                     Vinay Arora
                                        CSED
Program – 2 (output)




                Vinay Arora
                   CSED
Program - 3
  #include<stdio.h>                                    void areaperi(int r, float *a, float *p)
  #include<conio.h>                                      {
  void areaperi(int,float *,float *);                     *a=3.14*r*r;
  int main()
                                                          *p=2*3.14*r;
   {
    int radius;                                          }
    float area, perimeter;
    clrscr();

   printf("Enter radius of circle");
   scanf("%d",&radius);

    areaperi(radius,&area,&perimeter);

   printf("Area=%fn",area);
   printf("Perimeter=%fn",perimeter);
   return 0;

   }
                                         Vinay Arora
                                            CSED
Program – 3 (output)




                Vinay Arora
                   CSED
Passing Array Value (CBVal)




                Vinay Arora
                   CSED
Passing Array Reference (CBRef)




                Vinay Arora
                   CSED
Vinay Arora
   CSED
Program - 4
        #include<stdio.h>
        #include<conio.h>
        void main()
         {
          int i, *x;
          clrscr();

         printf("Enter any Integer Valuet");
         scanf("%d",&i);

         x=&i;
         printf("nx=Address value of in");
         printf("nValue of x = %u",x);
         x++;
         printf("nAfter Increment in Pointern");
         printf("Value of x = %u",x);

          getch();
         }

                            Vinay Arora
                               CSED
Program – 4 (output)




                Vinay Arora
                   CSED
Program - 5
        #include<stdio.h>
        #include<conio.h>

        void main()
         {
          int a=10, b=20, *p, *j;

         clrscr();

         p=&a;
         j=&b;

         printf("nAddition *p + b = %d", *p + b);
         printf("nAddition *p + *j = %d", *p + *j);
         printf("nAddition *(p) + *(j) = %d", *(p) + *(j));
         printf("nAddition *(&a) + *(&b) = %d", *(&a) + *(&b));

          getch();
         }
                               Vinay Arora
                                  CSED
Program – 5 (output)




                Vinay Arora
                   CSED
Program - 6
  #include<stdio.h>
  #include<conio.h>                             printf("nj - i = %d",j-i);
                                                printf("n*j - *i =%d",*j - *i);
  void main()
   {                                            getch();
    int arr[]={10,20,30,45,67,56,74};           }
    int *i,*j;
    int x;

   clrscr();

   printf("Array Elements are");
   for(x=0;x<=6;x++)
    {
     printf("n Value at arr[%d] is %d",x,arr[x]);
    }

   i=&arr[1];
   j=&arr[5];

                                        Vinay Arora
                                           CSED
Program – 6 (output)




                Vinay Arora
                   CSED
Program - 7
  #include<stdio.h>                                   for(i=0;i<=5;i++)
  #include<conio.h>                                     {
                                                         printf("nAddress = %u",j);
  void main()                                            printf("nElement = %d",*j);
   {                                                     j++;
    int num[]={24,34,12,44,56,17};                      }
    int i,*j;
                                                        getch();
   clrscr();                                           }

   printf("Array Elements are");
   for(i=0;i<=5;i++)
    {
     printf("n Value at arr[%d] is %d",i,num[i]);
    }

   j=&num[0];


                                        Vinay Arora
                                           CSED
Program – 7 (output)




                Vinay Arora
                   CSED
Program – 8 (Diff. notations for accessing Array)

    #include<stdio.h>                                getch();
    #include<conio.h>                                 }

    void main()
     {
      int num[]={24,34,12};
      int i;

     clrscr();

     printf("Array Elements are");
     for(i=0;i<=2;i++)
      {
       printf("n Value at arr[%d] is %d",i,num[i]);
       printf("n Value at arr[%d] is %d",i,i[num]);
       printf("n Value at arr[%d] is %d",i,*(num+i));
       printf("n Value at arr[%d] is %d",i,*(i+num));
       printf("n");
      }
                                       Vinay Arora
                                          CSED
Program – 8 (output)




                Vinay Arora
                   CSED
Program - 9
         #include<stdio.h>
         #include<conio.h>

         void main()
          {
           int s[3][2]={
                                  {10,15},
                                  {20,25},
                                  {30,35}
                           };
          int i;
          clrscr();

          for(i=0;i<=2;i++)
           printf("Address of %dth 1-D array = %un",i,s[i]);

           getch();
          }

                                Vinay Arora
                                   CSED
Program – 9 (output)




                Vinay Arora
                   CSED
Program – 10 (Conti…)

  #include<stdio.h>                           printf("Notation Used is s[i][j])n");
  #include<conio.h>                            for(i=0;i<=2;i++)
  void main()                                   {
   {                                             for(j=0;j<=1;j++)
    int s[3][2]={                                {
                      {10,15},                    printf("t%d",s[i][j]);
                      {20,25},                   }
                      {30,35}                   printf("n");
               };                               }
   int i,j;
   clrscr();                                       getch();
   printf("Array Elements aren");           }




                                     Vinay Arora
                                        CSED
Program – 10 (Conti…)

  #include<stdio.h>                 printf("nAccessing 2-D Arrayn");
  #include<conio.h>                  printf("Notation Used is *(s[i]+j)n");
  void main()                        for(i=0;i<=2;i++)
   {                                  {
    int s[3][2]={                      for(j=0;j<=1;j++)
                      {10,15},         {
                      {20,25},          printf("t%d",*(s[i]+j));
                      {30,35}          }
               };                     printf("n");
   int i,j;                           }
   clrscr();
                                   getch();
                                    }




                                 Vinay Arora
                                    CSED
Program – 10 (Conti…)

  #include<stdio.h>                printf("nAccessing 2-D Arrayn");
  #include<conio.h>                  printf("Notation Used is
  void main()                      *(*(s+i)+j)n");
   {                                 for(i=0;i<=2;i++)
    int s[3][2]={                     {
                      {10,15},         for(j=0;j<=1;j++)
                      {20,25},         {
                      {30,35}           printf("t%d",*(*(s+i)+j));
               };                      }
   int i,j;                           printf("n");
   clrscr();                          }
                                     getch();
                                    }




                                 Vinay Arora
                                    CSED
Program – 10 (output)




                Vinay Arora
                   CSED
Program – 11 (Array of Pointer)
 #include<stdio.h>             printf("Address of variable a,b,cn");
 #include<conio.h>               printf("%un",a);
                                 printf("%un",b);
 void main()                     printf("%un",c);
  {
    int *arr[3];                printf("Value Present in Arrayn");
    int i=10, j=20, k=30, m;    for(m=0;m<=2;m++)
    int *a,*b,*c;                {
                                 printf("n%u",arr[m]);
   clrscr();                     }

                                printf("n");                      printf("n");
   arr[0] = &i;                                                       for(m=0;m<=2;m++)
   arr[1] = &j;                 for(m=0;m<=2;m++)
                                 {                                     {
   arr[2] = &k;                                                        printf("n%d",*(arr[m]));
                                 printf("n%u",&arr[m]);
                                 }                                     }
   a=&i;                                                             getch();
   b=&j;                                                            }
   c=&k;

                                          Vinay Arora
                                             CSED
Program – 11 (output)




                Vinay Arora
                   CSED
Thnx…



  Vinay Arora
     CSED
Ad

More Related Content

What's hot (20)

Pointer in C++
Pointer in C++Pointer in C++
Pointer in C++
Mauryasuraj98
 
Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2Learning C++ - Pointers in c++ 2
Learning C++ - Pointers in c++ 2
Ali Aminian
 
Lecturer23 pointersin c.ppt
Lecturer23 pointersin c.pptLecturer23 pointersin c.ppt
Lecturer23 pointersin c.ppt
eShikshak
 
Pointers in C
Pointers in CPointers in C
Pointers in C
Vijayananda Ratnam Ch
 
Pointers+(2)
Pointers+(2)Pointers+(2)
Pointers+(2)
Rubal Bansal
 
Pointers in C/C++ Programming
Pointers in C/C++ ProgrammingPointers in C/C++ Programming
Pointers in C/C++ Programming
Faisal Shahzad Khan
 
Pointer in C
Pointer in CPointer in C
Pointer in C
bipchulabmki
 
Pointer in C
Pointer in CPointer in C
Pointer in C
Sonya Akter Rupa
 
Used of Pointer in C++ Programming
Used of Pointer in C++ ProgrammingUsed of Pointer in C++ Programming
Used of Pointer in C++ Programming
Abdullah Jan
 
C pointers
C pointersC pointers
C pointers
Aravind Mohan
 
Ponters
PontersPonters
Ponters
Mukund Trivedi
 
Ch5 array nota
Ch5 array notaCh5 array nota
Ch5 array nota
Hattori Sidek
 
Pointer in c program
Pointer in c programPointer in c program
Pointer in c program
Rumman Ansari
 
Pointers in c++ by minal
Pointers in c++ by minalPointers in c++ by minal
Pointers in c++ by minal
minal kumar soni
 
Pointers in C
Pointers in CPointers in C
Pointers in C
guestdc3f16
 
Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)Pointers (Pp Tminimizer)
Pointers (Pp Tminimizer)
tech4us
 
Pointers in C
Pointers in CPointers in C
Pointers in C
Kamal Acharya
 
Presentation on pointer.
Presentation on pointer.Presentation on pointer.
Presentation on pointer.
Md. Afif Al Mamun
 
Arrays
ArraysArrays
Arrays
Saranya saran
 
8 Pointers
8 Pointers8 Pointers
8 Pointers
Praveen M Jigajinni
 

Viewers also liked (20)

Pointers in C Programming
Pointers in C ProgrammingPointers in C Programming
Pointers in C Programming
Jasleen Kaur (Chandigarh University)
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
Pointers in c
Pointers in cPointers in c
Pointers in c
Saket Pathak
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
vinay arora
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
hossam nassar
 
C Tutorial
C TutorialC Tutorial
C Tutorial
biochelo
 
C programming tutorial
C programming tutorialC programming tutorial
C programming tutorial
Mohammed Jawad Ibne Ishaque (Taki)
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
vinay arora
 
Pointers in c
Pointers in cPointers in c
Pointers in c
Mohd Arif
 
C Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and ConstantsC Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and Constants
vinay arora
 
C Prog. - ASCII Values, Break, Continue
C Prog. -  ASCII Values, Break, ContinueC Prog. -  ASCII Values, Break, Continue
C Prog. - ASCII Values, Break, Continue
vinay arora
 
C Prog - Functions
C Prog - FunctionsC Prog - Functions
C Prog - Functions
vinay arora
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
vinay arora
 
C programming slide-6
C programming slide-6C programming slide-6
C programming slide-6
pradeep dwivedi
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
vinay arora
 
Pointers C programming
Pointers  C programmingPointers  C programming
Pointers C programming
Appili Vamsi Krishna
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphics
vinay arora
 
Pointers
PointersPointers
Pointers
sarith divakar
 
Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
vinay arora
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
argusacademy
 
INTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMINGINTRODUCTION TO C PROGRAMMING
INTRODUCTION TO C PROGRAMMING
Abhishek Dwivedi
 
C Tutorial
C TutorialC Tutorial
C Tutorial
biochelo
 
C Prog. - Structures
C Prog. - StructuresC Prog. - Structures
C Prog. - Structures
vinay arora
 
Pointers in c
Pointers in cPointers in c
Pointers in c
Mohd Arif
 
C Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and ConstantsC Prog. - Data Types, Variables and Constants
C Prog. - Data Types, Variables and Constants
vinay arora
 
C Prog. - ASCII Values, Break, Continue
C Prog. -  ASCII Values, Break, ContinueC Prog. -  ASCII Values, Break, Continue
C Prog. - ASCII Values, Break, Continue
vinay arora
 
C Prog - Functions
C Prog - FunctionsC Prog - Functions
C Prog - Functions
vinay arora
 
C Prog. - Strings (Updated)
C Prog. - Strings (Updated)C Prog. - Strings (Updated)
C Prog. - Strings (Updated)
vinay arora
 
C Prog. - Decision & Loop Controls
C Prog. - Decision & Loop ControlsC Prog. - Decision & Loop Controls
C Prog. - Decision & Loop Controls
vinay arora
 
CG - Introduction to Computer Graphics
CG - Introduction to Computer GraphicsCG - Introduction to Computer Graphics
CG - Introduction to Computer Graphics
vinay arora
 
Search engine and web crawler
Search engine and web crawlerSearch engine and web crawler
Search engine and web crawler
vinay arora
 
C programming pointer
C  programming pointerC  programming pointer
C programming pointer
argusacademy
 
Ad

Similar to C Prog - Pointers (20)

Chapter 8 c solution
Chapter 8 c solutionChapter 8 c solution
Chapter 8 c solution
Azhar Javed
 
Cpds lab
Cpds labCpds lab
Cpds lab
praveennallavelly08
 
C Prog - Strings
C Prog - StringsC Prog - Strings
C Prog - Strings
vinay arora
 
C programs Set 2
C programs Set 2C programs Set 2
C programs Set 2
Koshy Geoji
 
ADA FILE
ADA FILEADA FILE
ADA FILE
Gaurav Singh
 
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU HyderabadSrinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu, CPDS, CP Lab, JNTU Hyderabad
Srinivas Reddy Amedapu
 
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH HyderabadSrinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu C and Data Structures JNTUH Hyderabad
Srinivas Reddy Amedapu
 
Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02Daapracticals 111105084852-phpapp02
Daapracticals 111105084852-phpapp02
Er Ritu Aggarwal
 
C basics
C basicsC basics
C basics
MSc CST
 
DAA Lab File C Programs
DAA Lab File C ProgramsDAA Lab File C Programs
DAA Lab File C Programs
Kandarp Tiwari
 
C lab manaual
C lab manaualC lab manaual
C lab manaual
manoj11manu
 
Ejercicios de programacion
Ejercicios de programacionEjercicios de programacion
Ejercicios de programacion
Jeff Tu Pechito
 
Pnno
PnnoPnno
Pnno
shristichaudhary4
 
C lab excellent
C lab excellentC lab excellent
C lab excellent
Srinivas Reddy Amedapu
 
C and Data Structures
C and Data Structures C and Data Structures
C and Data Structures
Srinivas Reddy Amedapu
 
C and Data Structures Lab Solutions
C and Data Structures Lab SolutionsC and Data Structures Lab Solutions
C and Data Structures Lab Solutions
Srinivas Reddy Amedapu
 
C Prog - Array
C Prog - ArrayC Prog - Array
C Prog - Array
vinay arora
 
C Programming Language Part 8
C Programming Language Part 8C Programming Language Part 8
C Programming Language Part 8
Rumman Ansari
 
C Programming Example
C Programming ExampleC Programming Example
C Programming Example
PRATHAMESH DESHPANDE
 
SaraPIC
SaraPICSaraPIC
SaraPIC
Sara Sahu
 
Ad

More from vinay arora (20)

Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
vinay arora
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
vinay arora
 
Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
vinay arora
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
vinay arora
 
6 java - loop
6  java - loop6  java - loop
6 java - loop
vinay arora
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
vinay arora
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
vinay arora
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
vinay arora
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
vinay arora
 
Uta005 lecture3
Uta005 lecture3Uta005 lecture3
Uta005 lecture3
vinay arora
 
Uta005 lecture1
Uta005 lecture1Uta005 lecture1
Uta005 lecture1
vinay arora
 
Uta005 lecture2
Uta005 lecture2Uta005 lecture2
Uta005 lecture2
vinay arora
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protection
vinay arora
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
vinay arora
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
vinay arora
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devices
vinay arora
 
A&D - UML
A&D - UMLA&D - UML
A&D - UML
vinay arora
 
A&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLA&D - Object Oriented Design using UML
A&D - Object Oriented Design using UML
vinay arora
 
A&D - Input Design
A&D - Input DesignA&D - Input Design
A&D - Input Design
vinay arora
 
Use case diagram (airport)
Use case diagram (airport)Use case diagram (airport)
Use case diagram (airport)
vinay arora
 
Use case diagram
Use case diagramUse case diagram
Use case diagram
vinay arora
 
Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)Lab exercise questions (AD & CD)
Lab exercise questions (AD & CD)
vinay arora
 
SEM - UML (1st case study)
SEM - UML (1st case study)SEM - UML (1st case study)
SEM - UML (1st case study)
vinay arora
 
4 java - decision
4  java - decision4  java - decision
4 java - decision
vinay arora
 
3 java - variable type
3  java - variable type3  java - variable type
3 java - variable type
vinay arora
 
2 java - operators
2  java - operators2  java - operators
2 java - operators
vinay arora
 
1 java - data type
1  java - data type1  java - data type
1 java - data type
vinay arora
 
Security & Protection
Security & ProtectionSecurity & Protection
Security & Protection
vinay arora
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
vinay arora
 
CG - Output Primitives
CG - Output PrimitivesCG - Output Primitives
CG - Output Primitives
vinay arora
 
CG - Display Devices
CG - Display DevicesCG - Display Devices
CG - Display Devices
vinay arora
 
CG - Input Output Devices
CG - Input Output DevicesCG - Input Output Devices
CG - Input Output Devices
vinay arora
 
A&D - Object Oriented Design using UML
A&D - Object Oriented Design using UMLA&D - Object Oriented Design using UML
A&D - Object Oriented Design using UML
vinay arora
 
A&D - Input Design
A&D - Input DesignA&D - Input Design
A&D - Input Design
vinay arora
 

Recently uploaded (20)

Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Redesigning Education as a Cognitive Ecosystem: Practical Insights into Emerg...
Leonel Morgado
 
How to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 WebsiteHow to Configure Extra Steps During Checkout in Odoo 18 Website
How to Configure Extra Steps During Checkout in Odoo 18 Website
Celine George
 
Pope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptxPope Leo XIV, the first Pope from North America.pptx
Pope Leo XIV, the first Pope from North America.pptx
Martin M Flynn
 
Module 1: Foundations of Research
Module 1: Foundations of ResearchModule 1: Foundations of Research
Module 1: Foundations of Research
drroxannekemp
 
Final Evaluation.docx...........................
Final Evaluation.docx...........................Final Evaluation.docx...........................
Final Evaluation.docx...........................
l1bbyburrell
 
How to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 PurchaseHow to Manage Amounts in Local Currency in Odoo 18 Purchase
How to Manage Amounts in Local Currency in Odoo 18 Purchase
Celine George
 
Chemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptxChemotherapy of Malignancy -Anticancer.pptx
Chemotherapy of Malignancy -Anticancer.pptx
Mayuri Chavan
 
How to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo SlidesHow to Add Button in Chatter in Odoo 18 - Odoo Slides
How to Add Button in Chatter in Odoo 18 - Odoo Slides
Celine George
 
Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)Myasthenia gravis (Neuromuscular disorder)
Myasthenia gravis (Neuromuscular disorder)
Mohamed Rizk Khodair
 
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docxPeer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
Peer Assessment_ Unit 2 Skills Development for Live Performance - for Libby.docx
19lburrell
 
Cyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top QuestionsCyber security COPA ITI MCQ Top Questions
Cyber security COPA ITI MCQ Top Questions
SONU HEETSON
 
Rebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter worldRebuilding the library community in a post-Twitter world
Rebuilding the library community in a post-Twitter world
Ned Potter
 
Botany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic ExcellenceBotany Assignment Help Guide - Academic Excellence
Botany Assignment Help Guide - Academic Excellence
online college homework help
 
puzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tensepuzzle Irregular Verbs- Simple Past Tense
puzzle Irregular Verbs- Simple Past Tense
OlgaLeonorTorresSnch
 
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptxUnit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Unit 5 ACUTE, SUBACUTE,CHRONIC TOXICITY.pptx
Mayuri Chavan
 
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFAMCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
MCQS (EMERGENCY NURSING) DR. NASIR MUSTAFA
Dr. Nasir Mustafa
 
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
Mental Health Assessment in 5th semester bsc. nursing and also used in 2nd ye...
parmarjuli1412
 
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptxANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
ANTI-VIRAL DRUGS unit 3 Pharmacology 3.pptx
Mayuri Chavan
 
spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)spinal cord disorders (Myelopathies and radiculoapthies)
spinal cord disorders (Myelopathies and radiculoapthies)
Mohamed Rizk Khodair
 

C Prog - Pointers

  • 1. C Programming - Pointers Organized By: Vinay Arora Assistant Professor, CSED Thapar University, Patiala
  • 2. Program - 1 #include<stdio.h> void swapr(int x, int y) #include<conio.h> { void swapr(int,int); int t; int main() t=x; { x=y; int a=10,b=20; y=t; clrscr(); } printf("Value of variable a=%d and b=%d",a,b); swapr(a,b); printf("nValue of variable a=%d and b=%d",a,b); getch(); } Vinay Arora CSED
  • 3. Program – 1 (output) Vinay Arora CSED
  • 4. Program - 2 #include<stdio.h> void swapr(int *x, int *y) #include<conio.h> { void swapr(int *, int *); int t; int main() t=*x; { *x=*y; int a=10,b=20; *y=t; clrscr(); } printf("Value of variable a=%d and b=%d",a,b); swapr(&a,&b); printf("nValue of variable a=%d and b=%d",a,b); getch(); } Vinay Arora CSED
  • 5. Program – 2 (output) Vinay Arora CSED
  • 6. Program - 3 #include<stdio.h> void areaperi(int r, float *a, float *p) #include<conio.h> { void areaperi(int,float *,float *); *a=3.14*r*r; int main() *p=2*3.14*r; { int radius; } float area, perimeter; clrscr(); printf("Enter radius of circle"); scanf("%d",&radius); areaperi(radius,&area,&perimeter); printf("Area=%fn",area); printf("Perimeter=%fn",perimeter); return 0; } Vinay Arora CSED
  • 7. Program – 3 (output) Vinay Arora CSED
  • 8. Passing Array Value (CBVal) Vinay Arora CSED
  • 9. Passing Array Reference (CBRef) Vinay Arora CSED
  • 10. Vinay Arora CSED
  • 11. Program - 4 #include<stdio.h> #include<conio.h> void main() { int i, *x; clrscr(); printf("Enter any Integer Valuet"); scanf("%d",&i); x=&i; printf("nx=Address value of in"); printf("nValue of x = %u",x); x++; printf("nAfter Increment in Pointern"); printf("Value of x = %u",x); getch(); } Vinay Arora CSED
  • 12. Program – 4 (output) Vinay Arora CSED
  • 13. Program - 5 #include<stdio.h> #include<conio.h> void main() { int a=10, b=20, *p, *j; clrscr(); p=&a; j=&b; printf("nAddition *p + b = %d", *p + b); printf("nAddition *p + *j = %d", *p + *j); printf("nAddition *(p) + *(j) = %d", *(p) + *(j)); printf("nAddition *(&a) + *(&b) = %d", *(&a) + *(&b)); getch(); } Vinay Arora CSED
  • 14. Program – 5 (output) Vinay Arora CSED
  • 15. Program - 6 #include<stdio.h> #include<conio.h> printf("nj - i = %d",j-i); printf("n*j - *i =%d",*j - *i); void main() { getch(); int arr[]={10,20,30,45,67,56,74}; } int *i,*j; int x; clrscr(); printf("Array Elements are"); for(x=0;x<=6;x++) { printf("n Value at arr[%d] is %d",x,arr[x]); } i=&arr[1]; j=&arr[5]; Vinay Arora CSED
  • 16. Program – 6 (output) Vinay Arora CSED
  • 17. Program - 7 #include<stdio.h> for(i=0;i<=5;i++) #include<conio.h> { printf("nAddress = %u",j); void main() printf("nElement = %d",*j); { j++; int num[]={24,34,12,44,56,17}; } int i,*j; getch(); clrscr(); } printf("Array Elements are"); for(i=0;i<=5;i++) { printf("n Value at arr[%d] is %d",i,num[i]); } j=&num[0]; Vinay Arora CSED
  • 18. Program – 7 (output) Vinay Arora CSED
  • 19. Program – 8 (Diff. notations for accessing Array) #include<stdio.h> getch(); #include<conio.h> } void main() { int num[]={24,34,12}; int i; clrscr(); printf("Array Elements are"); for(i=0;i<=2;i++) { printf("n Value at arr[%d] is %d",i,num[i]); printf("n Value at arr[%d] is %d",i,i[num]); printf("n Value at arr[%d] is %d",i,*(num+i)); printf("n Value at arr[%d] is %d",i,*(i+num)); printf("n"); } Vinay Arora CSED
  • 20. Program – 8 (output) Vinay Arora CSED
  • 21. Program - 9 #include<stdio.h> #include<conio.h> void main() { int s[3][2]={ {10,15}, {20,25}, {30,35} }; int i; clrscr(); for(i=0;i<=2;i++) printf("Address of %dth 1-D array = %un",i,s[i]); getch(); } Vinay Arora CSED
  • 22. Program – 9 (output) Vinay Arora CSED
  • 23. Program – 10 (Conti…) #include<stdio.h> printf("Notation Used is s[i][j])n"); #include<conio.h> for(i=0;i<=2;i++) void main() { { for(j=0;j<=1;j++) int s[3][2]={ { {10,15}, printf("t%d",s[i][j]); {20,25}, } {30,35} printf("n"); }; } int i,j; clrscr(); getch(); printf("Array Elements aren"); } Vinay Arora CSED
  • 24. Program – 10 (Conti…) #include<stdio.h> printf("nAccessing 2-D Arrayn"); #include<conio.h> printf("Notation Used is *(s[i]+j)n"); void main() for(i=0;i<=2;i++) { { int s[3][2]={ for(j=0;j<=1;j++) {10,15}, { {20,25}, printf("t%d",*(s[i]+j)); {30,35} } }; printf("n"); int i,j; } clrscr(); getch(); } Vinay Arora CSED
  • 25. Program – 10 (Conti…) #include<stdio.h> printf("nAccessing 2-D Arrayn"); #include<conio.h> printf("Notation Used is void main() *(*(s+i)+j)n"); { for(i=0;i<=2;i++) int s[3][2]={ { {10,15}, for(j=0;j<=1;j++) {20,25}, { {30,35} printf("t%d",*(*(s+i)+j)); }; } int i,j; printf("n"); clrscr(); } getch(); } Vinay Arora CSED
  • 26. Program – 10 (output) Vinay Arora CSED
  • 27. Program – 11 (Array of Pointer) #include<stdio.h> printf("Address of variable a,b,cn"); #include<conio.h> printf("%un",a); printf("%un",b); void main() printf("%un",c); { int *arr[3]; printf("Value Present in Arrayn"); int i=10, j=20, k=30, m; for(m=0;m<=2;m++) int *a,*b,*c; { printf("n%u",arr[m]); clrscr(); } printf("n"); printf("n"); arr[0] = &i; for(m=0;m<=2;m++) arr[1] = &j; for(m=0;m<=2;m++) { { arr[2] = &k; printf("n%d",*(arr[m])); printf("n%u",&arr[m]); } } a=&i; getch(); b=&j; } c=&k; Vinay Arora CSED
  • 28. Program – 11 (output) Vinay Arora CSED
  • 29. Thnx… Vinay Arora CSED
  翻译: