Hello,
Here are the solutions to the practice questions. Sorry I'm late with posting those but it was a busy day.
Please don't spend too much time with question #6. If you are comfortable with the first five questions, you should be fine with the ones in the final too. :-)
Question 1
Question 2
Question 3
Question 4
Question 5
Question 6 [This is not the best (i.e. most efficient) way of solving this problem, but it is intuitive.]
See you tomorrow at 3 pm!
Tuesday, May 19, 2009
Monday, May 18, 2009
Practice Questions
Hello,
Here are some practice questions for programming:
1. Ask the user to enter a number and tell the user if the number she entered is a multiple of 8.
2. Ask the user to enter 10 numbers and tell how many of those numbers are even, and how many of them are odd.
3. Print all the integers that are between 1 and 100 and are multiples of 6, but not 10.
Your output should look like this:
6, 12, 18, 24, 36, 42, 48, 54, 66, ..., 96.
4. Write a program that asks the user to enter positive integers. As long as the number the user enters is a positive integer, the program should keep asking for another one. If the user enters 0 or a negative integer, the program should stop asking for more numbers and it should output the sum of the positive integers it has read so far.
5. Write a program that asks the user to make a choice by entering A or B or C. If the letter the user has entered is not one of those, the program should keep asking for the choice. If it is one of those letters, it should print the user's choice and stop.
6. (Relatively difficult) A prime number is a natural number that has only two natural number divisors: 1 and itself. Write a program that finds out and outputs the first 5 prime numbers.
So the output of your program should be: 2, 3, 5, 7, 11.
Here are some practice questions for programming:
1. Ask the user to enter a number and tell the user if the number she entered is a multiple of 8.
2. Ask the user to enter 10 numbers and tell how many of those numbers are even, and how many of them are odd.
3. Print all the integers that are between 1 and 100 and are multiples of 6, but not 10.
Your output should look like this:
6, 12, 18, 24, 36, 42, 48, 54, 66, ..., 96.
4. Write a program that asks the user to enter positive integers. As long as the number the user enters is a positive integer, the program should keep asking for another one. If the user enters 0 or a negative integer, the program should stop asking for more numbers and it should output the sum of the positive integers it has read so far.
5. Write a program that asks the user to make a choice by entering A or B or C. If the letter the user has entered is not one of those, the program should keep asking for the choice. If it is one of those letters, it should print the user's choice and stop.
6. (Relatively difficult) A prime number is a natural number that has only two natural number divisors: 1 and itself. Write a program that finds out and outputs the first 5 prime numbers.
So the output of your program should be: 2, 3, 5, 7, 11.
Thursday, May 14, 2009
Final Exam Topics and Programs from the Last Two Classes
Here are the topics you should study for the final:
- Number systems, conversions, overflow
- Logic gates and truth tables
- Machine language programming
- Algorithms, efficiency of algorithms
- C++ programming (I will hand out a sample program so you don't need to memorize the syntax of the commands. Please focus on how to solve a given problem instead.)
I'm also posting the programs from May 11 and May 13. The latter one has an extra example I talked about in class but haven't written the program for.
- Number systems, conversions, overflow
- Logic gates and truth tables
- Machine language programming
- Algorithms, efficiency of algorithms
- C++ programming (I will hand out a sample program so you don't need to memorize the syntax of the commands. Please focus on how to solve a given problem instead.)
I'm also posting the programs from May 11 and May 13. The latter one has an extra example I talked about in class but haven't written the program for.
Wednesday, May 13, 2009
Monday, May 11, 2009
Homework #5 and C++ Assignments I have NOT received
Hello everybody,
Homework #5 is up now.
Here is the list of students whose homework #3 I haven't received:
- Omer
- Rachel
- Mattheuw
- Anthony
Here is the list of students whose homework #4 I haven't received:
I won't take off points for homework #4 if you send it to me by Tuesday midnight.
My email address is cagiltasdemir AT gmail DOT com
- Aymen
- Kareem
- Emily
- Duan
- Yu
- Roxana
- Omer
- Jenny F.
- Mattheuw
- Anthony
- Shifat
- Brian
- Amid
Homework #5 is up now.
Here is the list of students whose homework #3 I haven't received:
- Omer
- Rachel
- Mattheuw
- Anthony
Here is the list of students whose homework #4 I haven't received:
I won't take off points for homework #4 if you send it to me by Tuesday midnight.
My email address is cagiltasdemir AT gmail DOT com
- Aymen
- Kareem
- Emily
- Duan
- Yu
- Roxana
- Omer
- Jenny F.
- Mattheuw
- Anthony
- Shifat
- Brian
- Amid
Wednesday, May 6, 2009
Programs - May 6 and Homework #4
Hello,
I'm posting the two programs from today's class: May6.pdf
Here is the link to Homework #4: Homework4.pdf
It's due Monday night.
Have a good weekend!
I'm posting the two programs from today's class: May6.pdf
Here is the link to Homework #4: Homework4.pdf
It's due Monday night.
Have a good weekend!
Correction
Hi all,
There was a mistake in the block count program (April29.pdf). In the previous version I had forgot to ask the user for the number of levels in the pyramid. I've corrected it, so please download that file again.
April29.pdf
There was a mistake in the block count program (April29.pdf). In the previous version I had forgot to ask the user for the number of levels in the pyramid. I've corrected it, so please download that file again.
April29.pdf
Subscribe to:
Posts (Atom)