Question

Computer Science Midterm Exam Review Questions 11. What is a pointer? 12. Are pointers and array...

Computer Science Midterm Exam Review Questions

11. What is a pointer?

12. Are pointers and array names the same thing? How are they alike? How do they differ?

0 0
Add a comment Improve this question Transcribed image text
Answer #1

11

Ans:

Pointer: Pointer is variable which stores the address of a variable .

Ex:

int num=10;

int *ptr=&num ; // it means here ptr is a pointer variable and we are storing address of num in this pointer variable

Ex:

int a[10];

int *ptr=a; // here ptr is a pointer variable and we are storing the base address of array in this array variable.

12

Ans:

Yes we can assume that both pointers and array names are same thing.

But sometimes we use array names and some times we use pointer to that array

Ex:

If we want to interate through the array in the main function then

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

printf("%d",a[i]); // here this a[i] prints all elements of array;

If we want to pass the array to some function and we have to print array values then we use pointers

void printing(int *arr,int arr_len)

int i=0;

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

printf("%d",(arr+i)*); // here it will print array values

int main()
int a[10],n=10;

printing(a,n);

Add a comment
Know the answer?
Add Answer to:
Computer Science Midterm Exam Review Questions 11. What is a pointer? 12. Are pointers and array...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Computer Science Midterm Exam Review Questions 5. What is a struct, and how do you declare...

    Computer Science Midterm Exam Review Questions 5. What is a struct, and how do you declare one? 6. Define a struct and use it to solve a simple problem. 7. What is the main difference between structs in C and C++

  • Computer Science Midterm Exam Review Questions 21. How do you dynamically allocate variables in C++? 22....

    Computer Science Midterm Exam Review Questions 21. How do you dynamically allocate variables in C++? 22. How do you dynamically allocate an array in C++? 23. How do you deallocate variables in C++? 24. How do you deallocate arrays in C++? 25. How do you dynamically allocate memory in C? 26. How do you deallocate memory in C?

  • I have some questions about pointers/pointer arithmetic in C++ 1) Pointers and Pointer Arithmetic a.)       What...

    I have some questions about pointers/pointer arithmetic in C++ 1) Pointers and Pointer Arithmetic a.)       What is the difference between statically allocated arrays and dynamically allocated arrays (be brief) b.)      Which of the following pointers can be used for a dynamically allocated array? (Circle) char ptr; char * ptr; char ptr *; char ptr[]; char [] ptr; c.)       Show now, using that pointer, how to dynamically allocate array of characters of size 10: (don't use malloc) d.)      Which of the...

  • computer science

    CSCI 3000 Homework 4In this assignment, you will implement a simple version of Computer Lab administration system in C++. Your program will monitor computers in 4 computer labs and will allow users to log in and log out. Each computer lab has different number of computers.·      Lab 1 has 10 computers·      Lab 2 has 6 computers·      Lab 3 has 3 computers·      Lab 4 has 12 computersHere is a sample state of the system:Lab ArraySome of the computers are free (no...

  • home / study / engineering / computer science / computer science questions and answers / in...

    home / study / engineering / computer science / computer science questions and answers / in basic c please with comments so i can redo it on my own, thank you! for this lab, you only ... Question: In basic C please with comments so I can redo It on my own, thank you! For this lab, you only nee... In basic C please with comments so I can redo It on my own, thank you! For this lab, you...

  • Is for study for an exam, thanks. Some Review Questions/Exercises • • Convert a * b/c...

    Is for study for an exam, thanks. Some Review Questions/Exercises • • Convert a * b/c - d to posfix notation Provide an algorithm and evaluate the following postfix expression: 8 3 / 4 + Explain how we can use a deque to implement a queue. What are two possible prototypes for the pop() operation? Why is it more difficult to implement a queue with an array than implementing a . stack with an array? •

  • Stuck on this computer science assignment Write a program that demonstrates binary searching through an array...

    Stuck on this computer science assignment Write a program that demonstrates binary searching through an array of strings and finding specific values in an corresponding parallel double array. In all cases your output should exactly match the provided solution.o. Provided files: Assignment.cpp - starter assignment with function prototypes companies.txt - file for program to read. earnings.txt - file for program to read. Input1.txt Input2.txt - Test these inputs out manually, or use stream redirection Input3.txt - These inputs are based...

  • 80% of the employees in a specialized department of a large software firm are computer science graduates. A project team is made up of 8 employees. Part a) What is the probability to 3 decimal digits that all the project team members are computer science

    80% of the employees in a specialized department of a large software firm are computer science graduates. A project team is made up of 8 employees.Part a) What is the probability to 3 decimal digits that all the project team members are computer science graduates? Part b) What is the probability to 3 decimal digits that exactly 3 of the project team members are computer science graduates? Part c) What is the most likely number of computer science graduates among the 8 project team members?...

  • Computer science question 1.I am thinking about my birthday. How many yes/no questions would you have...

    Computer science question 1.I am thinking about my birthday. How many yes/no questions would you have to ask me to find out which month I was born in? A. 12 B. 6 C. At least 3, but possibly 4. D. At least 4 E. log2(2^12) 2.Now you have to guess everyoneʼs birth month. What is the average number of yes/no questions you will have to ask everyone? A. 12 B. 6 C. ⌈ log2(12) ⌉ D. log2(12) E. log2(2^12)

  • Can these questions be answered for my midterm review? Thank you! 1) Suppose a company purchased...

    Can these questions be answered for my midterm review? Thank you! 1) Suppose a company purchased land and a building for $16,225,538 cash. The appraised value of the building was $12,355,025, and the land was appraised at $7,784,271. What dollar amount of the purchase price will be allocated to the Building account? *Note: for calculations, please do not round the percentage. 2) At the beginning of 2023, Apu purchases a new Squishee machine for the Kwik-E-Mart with a cost of...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT