hw3 - CS2022 Introduction to C, Spring 2009 Homework 3 Due...

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

View Full Document Right Arrow Icon

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

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

Unformatted text preview: CS2022 Introduction to C, Spring 2009 Homework 3 Due Friday Feb 13. Attempt all problems, and email the codes for all except problems 1 and 2. Assume that all inputs are nice: There is no need to write code to check for bad user input in codes. Problem 1 (Fixing a problem in HW2) You have seen that the code segment int* x,y; parses in a way that makes y an integer instead of a pointer to an integer. Show how you can define a data type int_ptr so that the code int_ptr x,y; makes both x and y pointers to integers. The solution I have in mind is just a single line. Problem 2 (Macros) By the end of the program, are both x1 and x2 equal? How about y1 and y2? Why? #define SQUARE_MACRO(x) (x)*(x) double square_function(double x){ return x*x; } int main(){ double x1=1,x2=1,y1,y2; y1=SQUARE_MACRO(x1++); y2=square_function(x2++); } Problem 3 (Reversing a string, experimenting safe user input) Write a function that takes in a string as input, and then displays the reverse...
View Full Document

This note was uploaded on 01/10/2010 for the course CS 2022 taught by Professor Crandall during the Spring '08 term at Cornell University (Engineering School).

Page1 / 2

hw3 - CS2022 Introduction to C, Spring 2009 Homework 3 Due...

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