Lecture09-w04-LIN-09232019-LoopExamples.pdf - Computing I COMP.1010 Fall 2019 Lecture 9 loop examples By Sirong Lin PhD University of Massachusetts

Lecture09-w04-LIN-09232019-LoopExamples.pdf - Computing I...

This preview shows page 1 - 9 out of 24 pages.

Computing I By: Sirong Lin, PhD University of Massachusetts Lowell COMP.1010, Fall 2019 Lecture 9: loop examples
Image of page 1
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Upcoming Due Dates 2 Due Date Daily 07 09-23-2019 (M), 9:00pm Week 04 Readings MWF, 9:00am Week 04 Practice 09-29-2019 (Su), 9:00pm Daily 08 09-25-2019 (W), 9:00pm Daily 09 09-27-2019 (F), 9:00pm Daily 01-04 Resubmission 09-30-2019 (M), 9:00pm HW1 10-02-2019 (W), in class
Image of page 2
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Homework Packet 1 Due: 10-2-2019 (W), in class finish the questions (1~58) by yourself find classmate(s) to study together, check answers, explain difference Q&A session in class on the due date Quiz 3
Image of page 3
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin Outline Learn more about loop 4
Image of page 4
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 5 While Loop Example 2 — Please enter 100! Read integer 100 from the keyboard. The program will keep asking for 100 if the user gives a different number (let’s assume only integers will be entered for now)
Image of page 5
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 6 While Loop Example 2 — Please enter 100! Recipe: 1. read an integer from the keyboard 2. check the integer, if it is 100, prints the number and ends the program 3. otherwise, repeat 1 and 2
Image of page 6
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 7 While Loop Example 2 — please enter 100 (Cont’d) use if statement, the program only asks one extra time #include <stdio.h> int main(int argc, char*argv[]) { int input; printf("Please enter 100:\n”); scanf("%d", &input); if (input != 100) { printf("I'm sorry, you must enter 100:\n”); scanf("%d", &input); } printf("Got %d!\n", input); return 0; }
Image of page 7
Work Ready Life Ready World Ready Computing I, F2019, By Dr. Sirong Lin 8
Image of page 8
Image of page 9

You've reached the end of your free preview.

Want to read all 24 pages?

  • Fall '15

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

Stuck? We have tutors online 24/7 who can help you get unstuck.
A+ icon
Ask Expert Tutors You can ask You can ask ( soon) You can ask (will expire )
Answers in as fast as 15 minutes
A+ icon
Ask Expert Tutors