hw2 - CS2022 Introduction to C, Spring 2009 Homework 2 Due...

Info iconThis preview shows pages 1–3. 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 2 Due Date: Wednesday February 4 Attempt all problems, except for problem 4, which is optional. Email code for the last two problems to cp229@cornell.edu. Problem 1 What happens when you run the following code? How can you correct this? (By the way, you are taking CS2022.) #include <stdio.h> int main(){ int x=02022; printf("I am taking CS%d.\n",x); return 0; } Problem 2 Why do some compilers not compile the following code? (As an aside, you might want to try compiling this on your C compiler. It does compile without problems in gcc in Linux.) #include <stdio.h> int main(){ printf("The value of foo(0) is: %d.\n",foo(0)); return 0; } int foo(int arg){ return 43; } Problem 3 The programmer wanted to do something which didnt turn out the way that was intended. Correct the code. int main(){ int i,n; n=25; 1 2 for (i=0;i<n;i++) printf("%f\n",(float) (i/n)); return 0; } Problem 4 (Optional: Not exactly C programming, but nice to know) Bitwise operations.Bitwise operations....
View Full Document

Page1 / 3

hw2 - CS2022 Introduction to C, Spring 2009 Homework 2 Due...

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

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