tutorial02 - CS1010E Programming Methodology Semester 1...

Info icon This 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 29 August – 2 September 2011 Tutorial 2 Basic C Elements 1. The Edit–Compile–Run cycle in program development is second nature to all pro- grammers. In essence, we use an editor ( vim ) to type out the source code/program, which is then compiled via a compiler ( gcc ) to machine executable instructions which is, in turn, executed/run. Experience the Edit–Compile–Run cycle by typing out the following program, compiling and executing it. Take note of any errors and rectify the program accordingly. #include <stdio.h> int main(void) { int cur, prev1 = 1, prev2 = 1; cur = prev1 + prev2; prev2 = prev1; prev1 = cur; cur = prev1 + prev2; prev2 = prev1; prev1 = cur; cur = prev1 + prev2; prev2 = prev1; prev1 = cur; printf("cur is %d; prev1 is %d; prev2 is %d\n", cur, prev1, prev2); return 0; } 2. Being able to trace through the execution of a program without going through the Edit– Compile–Run cycle is known as program tracing . Program tracing involves building up a mental model of program execution in your mind. By tracing a program, you will gain a stronger understanding of the program execution flow and improve your programming skill. Trace the execution of the program in question 1, paying particular attention to variable declarations and changes to the values of the variables. Verify
Image of page 1

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

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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern