EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Pointer Addition–Sum of elements of array with pointers

Pointer Addition–Sum of elements of array with pointers

|

Miscellaneous › Others › Pointer Addition–Sum of elements of array with pointers

  • This topic has 2 replies, 2 voices, and was last updated 12 years, 10 months ago by anupam.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • June 14, 2013 at 7:12 am #2483
    anupam
    Participant

    #include<stdio.h>

    main()

    {

         int a[5],sum=0,i;

         int *p,j;

         for ( i =0; i<5; i++)

         {

         printf(“Enter number:”);

         scanf(“%d”,&a);

         }

         // Normal Way of addition

         for (i=0;i<5;i++)

         {

              sum= sum + a;

         }

         printf(“nTotal sum is=%d”,sum);

             

             // With Pointers //

     

         sum=0;

         for (i=0;i<5;i++)

         {

              p=&a; // p holds the address of a

              sum=sum + *p; // *p holds the contents of a

         }

         printf(“nTotal sum is=%d”,sum);

         getch();

        

    }

     

    Output:

    Enter number:56

    Enter number:55

    Enter number:88

    Enter number:88

    Enter number:55

     

    Total sum is=342

    Total sum is=342

    June 18, 2013 at 2:10 pm #9981
    AJISH ALFRED
    Participant

    Is that a query?

    June 18, 2013 at 3:05 pm #9983
    anupam
    Participant

    no its not a query. its just addition of numbers using ‘C’ Language pointers. if u still have questions regarding pointers, u can ask me,

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • AI algorithm for bots April 17, 2026
  • SDCC Array Access In Timer 0 Interrupt Handler April 16, 2026
  • EasyEda program has a major bug April 16, 2026
  • ANOTHER OLD PROJECT REDO April 16, 2026
  • How to set the OSCAL in a PIC 12F675 April 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise