Example of pointers, C/C++ Programming

#include "stdafx.h"

#include iostream

using namespace std;

int _tmain(int argc, _TCHAR* argv[])

{

            int NumbHold[5];

            int * ptrNumb;

            ptrNumb= NumbHold; 

            *ptrNumb= 10;

            ptrNumb++; 

            *ptrNumb= 20;

            ptrNumb= &NumbHold[2]; 

            *ptrNumb= 30;

            ptrNumb= NumbHold + 3; 

            *ptrNumb= 40;

            ptrNumb= NumbHold; 

            *(ptrNumb+4) = 50;

            for (int n=0; n<5; n++)

                        cout << NumbHold[n] << ", ";

            cout << endl;

            return 0;

}

Output:

10, 20, 30, 40, 50, 
Posted Date: 4/1/2013 3:24:55 AM | Location : United States







Related Discussions:- Example of pointers, Assignment Help, Ask Question on Example of pointers, Get Answer, Expert's Help, Example of pointers Discussions

Write discussion on Example of pointers
Your posts are moderated
Related Questions
At a shop of marbles, packs of marbles are prepared. Packets are named A, B, C, D, E …….. All packets are kept in a VERTICAL SHELF in random order. Any numbers of packets with thes

how to write a c program for stone game

#queWrite a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points c

A: Provided that function parameter is "const reference", compiler create temporary variable in following two ways. a) The actual argument is the correct type, however it isn't

recsection method source code for searching position


Develop a C++ program that uses a while to determine the gross pay (in Dollars) for each of several employees. The company pays “straight-time” for the first 40 hours worked by eac

Aim: To implement a program for bank account using static data type. Code: class bank {             static int acc_no;             int acc;             float b

one of the applications of computers in numerical analysis is computing the area under a curve. one method of calculating the area under acurve is to divide the area int a number o

Objective Using C++ string, classes, constructors and member functions. Task A Write a program (book.cpp) to store a list of book titles and the published dates. Your pro