Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 4 (20 marks) (a) Write C-language statements to declare and initialise the following A variable of type integer with a value of 10 )

image text in transcribed
Question 4 (20 marks) (a) Write C-language statements to declare and initialise the following A variable of type integer with a value of 10 ) A one dimensional array with the following integer values: 1, 10, 6, 21, 10 (iii)A pointer to the variable defined in (1) (6 marks) (b) Explain, using appropriate examples, what the following operators are used for when using pointers in a C-program: () addressing operator () dereferencing operator (6 marks) (c) Consider the following C-Program function void swap (int , int B) int temp: temp = A; A = B; B = temp; The function is called from main() using the statement swap(x,y) where x and y are integers defined in main(). The intention is that the values of x and y in main() are swapped. () Explain why the function above fails to do what is required. (3 marks) (II) Re-write the function implementation of swap for it to achieve its purpose and show how it is called in main(). (Hint: use pointers)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Databases Technologies And Applications

Authors: Zongmin Ma

1st Edition

1599041219, 978-1599041216

More Books

Students also viewed these Databases questions

Question

Describe the patterns of business communication.

Answered: 1 week ago

Question

3. Provide two explanations for the effects of mass media

Answered: 1 week ago