Preview

It/218 Week 4 Day 5 Arrays vs Pointers Checkpoint

Good Essays
Open Document
Open Document
485 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
It/218 Week 4 Day 5 Arrays vs Pointers Checkpoint
CheckPoint : Arrays and Versus Pointers
Define the following and provide an example of each: * Pointer * Arrays
Answer the following questions and provide an example of each:
What is the difference between a one-dimensional and a two dimensional arrays?
Arrays store items that have the same type of data type like a group of employees’ names and social security numbers for a team of 2000 personal. Pointer is a variable that greatly extends the power and flexibility of a program, each memory location that is used to store data value has an address. The address provides the means for a PC hardware to reference a particular data item.
Ex. of an Array
// Ex4_02.cpp
// Demonstrating array initialization
#include < iostream >
#include < iomanip > using std::cout; using std::endl;
Available for download on
Wrox.com
Copyright © 2010 John Wiley & Sons, Inc. using std::setw; int main()
{
int value[5] = { 1, 2, 3 }; int junk [5]; cout < < endl; for(int i = 0; i < 5; i++) cout < < setw(12) < < value[i]; cout < < endl; for(int i = 0; i < 5; i++) cout < < setw(12) < < junk[i]; cout < < endl; return 0;
}
Ex. of a Pointer
// Ex4_05.cpp
// Exercising pointers
#include < iostream > using std::cout; using std::endl; using std::hex; using std::dec; int main()
{
long* pnumber(nullptr); // Pointer declaration & initialization long number1(55), number2(99); pnumber = & number1; // Store address in pointer
*pnumber += 11; // Increment number1 by 11 cout < < endl
< < "number1 = " < < number1
< < " & number1 = " < < hex < < pnumber; pnumber = & number2; // Change pointer to address of number2 number1 = *pnumber*10; // 10 times number2 cout < < endl
< < "number1 = " < < dec < < number1
< < " pnumber = " < < hex < < pnumber
Available for download on
Wrox.com
NOTE The

You May Also Find These Documents Helpful

  • Good Essays

    Unit 16 Ao1

    • 529 Words
    • 3 Pages

    Programs need to store data at some time during the execution of processes. Data is held in variables which are names containers for each piece of data. Each variable must be given a name so it can be referred to again and again throughout the program. It should be something that is recognisable because for example variable 1 would be soon forgotten in a substantial piece of code. Variable names cannot be the same as code words such as print or run.…

    • 529 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    POS355 Week 1 Individual

    • 574 Words
    • 2 Pages

    While in the hardware, memory management includes elements that store data such as random access memory chips, and memory caches. In the operating system, memory management involves the distribution of precise memory blocks to programs as the user requests adjustments. While at the application and program level, memory management ensures the availability of sufficient memory for the objects and data structures at all times for each program that is running.…

    • 574 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Comp 220

    • 1463 Words
    • 6 Pages

    Pointers are, essentially, address variables, or variables that hold as their value the address of other variables. In terms of memory management, they are very powerful devices, and they more closely and efficiently use the actual internal hardware registers of the microprocessor that the program operates on.…

    • 1463 Words
    • 6 Pages
    Good Essays
  • Powerful Essays

    Memory – Memory is the part of the computer that temporarily stores applications, documents, and stem operating information.…

    • 2127 Words
    • 9 Pages
    Powerful Essays
  • Good Essays

    c. Modify the program of Part b so that at the option of the user, it displays…

    • 300 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    3. Any piece of data that is stored in a computer’s memory must be stored as a…

    • 435 Words
    • 5 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Intro the Programming

    • 386 Words
    • 5 Pages

    The _______ is the memory address that is saved by the system when a method is called and is the location to which…

    • 386 Words
    • 5 Pages
    Satisfactory Essays
  • Powerful Essays

    It 210

    • 2960 Words
    • 12 Pages

    Although the value of a variable may change during execution of a program, in all our programs so far, a single value has been associated with each variable name at any given time. In this chapter, we will discuss the concept of an array—a collection of variables of the same type and referenced by the same name. We will discuss one-dimensional arrays (lists) at length and focus briefly on twodimensional arrays (tables). You will learn how to set up and use arrays to accomplish various tasks.…

    • 2960 Words
    • 12 Pages
    Powerful Essays
  • Good Essays

    Chapter 1 study guide

    • 672 Words
    • 3 Pages

    To identify the location in RAM, RAM uses an address for each unique memory location where a byte can be stored…

    • 672 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Relational Databases

    • 750 Words
    • 3 Pages

    There are many ways to store and access data. One of these ways is using a data base. A database is an integrated collection of logically related data elements that are organized into a common pool of data elements (O 'Brien & Marakas, 2011). These elements are stored in such a way that they are not dependent on any one program or any piece of hardware. Thus allows data to be shared easily between programs.…

    • 750 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Parallel Arrays

    • 427 Words
    • 2 Pages

    In contrast, many array data structures allow access to any element with a constant number of operations,…

    • 427 Words
    • 2 Pages
    Good Essays
  • Good Essays

    #include<stdio.h> #include<conio.h> #include<process.h> #include<string.h> #include<ctype.h> #define max 30 struct stack { char opstack[max]; int tos; }; void push(struct stack *,char); char pop(struct stack *); int prece(char ); void main() { int i,j=0,k,l; char ch,infix[max], postfix[max]; stack pq; pq.tos=-1; A: clrscr(); printf("\nEnter the infix string:\t"); gets(infix); for(i=0;infix[i]!='\0';i++) { if (infix[i]=='(') push(&pq,infix[i]); else if (isalpha(infix[i])) { postfix[j]=infix[i]; j++; } else if (infix[i]=='+'||infix[i]=='-'||infix[i]=='/'||infix[i]=='$'||infix[i]=='*') { if(pq.tos!=-1 && prece(pq.opstack[pq.tos])>=prece(infix[i])) {ch=pop(&pq); postfix[j]=ch; j++; } push(&pq,infix[i]); } else if (infix[i]==')')…

    • 279 Words
    • 2 Pages
    Good Essays
  • Good Essays

    The Last Ride Together

    • 666 Words
    • 3 Pages

    Write a program to input a start limit S (S>0) and the last limit L (L>0). Print all the prime triplets between S and L (both inclusive), if S<=L otherwise your program should ask to re-enter the values of S and L again with a suitable error message.…

    • 666 Words
    • 3 Pages
    Good Essays
  • Satisfactory Essays

    POINTERS

    • 450 Words
    • 4 Pages

    Casa del Niño Jesus de Tayabas Pointers to Review Kinder I-St. Anne Name:_____________________________ Time: 8:00-9:15am Reading Letter Qq pp.139-143 Letter Rr pp.144-148 Letter Ss pp.149-153 Language I, You pp.195-203 He, She pp.207-209 Filipino Titik Tt pp.130-134 Titik Ww pp.135-139 Titik Yy pp.140-144…

    • 450 Words
    • 4 Pages
    Satisfactory Essays
  • Good Essays

    int function1(char x) { //parameter x passed to the function, function returns an integer value…

    • 1596 Words
    • 7 Pages
    Good Essays

Related Topics