tutorial07 - CS1010E Programming Methodology Semester 1...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
CS1010E Programming Methodology Semester 1 2011/2012 Week of 10 – 15 October 2011 Tutorial 7 Pointers 1. Study the following program fragment. int i1, i2; int *p1, *p2; i1 = 5; p1 = &i1; i2 = (*p1)/2 + 10; p2 = p1; Trace the code and give memory snapshots of the following. Verify your memory model by writing the program with appropriate printf statements. (a) What is the value of i1 ? (b) What is the value of i2 ? (c) What is the value of *p1 ? (d) What is the value of *p2 ? (e) What is the value of ? (f) What is the value of ? (g) What is the value of p1 ? (h) What is the value of p2 ? 2. Write a C program that re-arranges three input integers, each in the range of -100 to 100 (both inclusive), in ascending order. The following main function is given to you. int main(void) { int s, m, l; readValues(&s,&m,&l); reorder(&s, &m, &l); printf("The numbers reordered: %d %d %d\n", s, m, l); return 0; } (a) Write the function readValues to read in three integer values from the user and
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/13/2011 for the course ELECTRICAL CS1010E taught by Professor Henrytan during the Spring '11 term at National University of Singapore.

Page1 / 2

tutorial07 - CS1010E Programming Methodology Semester 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online