MC102

Computer Algorithms and Programming

First List of Exercises

The exercises on this list cover classes until 09/03.
  1. Make a program that prints the sentence: Hello World.
  2. Make a program that prints the word Hello on a line and the word world on the next line.
  3. Make a program that reads 2 numbers from the keyboard and print the sum of them.
  4. Make a program that reads 2 numbers on the keyboard and prints their addition and subtraction.
  5. Make a variation of the previous program that reads 3 numbers from the keyboard and prints the sum of them.
  6. Make a variation of the previous program that uses only 2 variables.
  7. Make a variation of the previous program that reads 4 numbers from the keyboard and prints the sum of them.
  8. Make a variation of the previous programs that reads a number n on the keyboard and then read n numbers and print the sum of them.
  9. Make a program that reads a person's year of birth and prints their age. Assume that the person already has a birthday this year.
  10. Make a program that prints all numbers between 1 and 100.
  11. Make a variation of the previous program that prints all even numbers between 1 and 100. Do not use the IF command.
  12. Make a variation of the previous program that uses the IF command to test whether each number is even or not.
  13. Make a program that reads two numbers: start e end and print all even numbers between start e end. (including limits if they are even).
  14. Make a program that reads 3 numbers: start, end e n and print all multiple numbers of n between start e end.
  15. Make a program that prints all multiples of 2 and 3 simultaneously. It is not worth testing just the multiplicity by 6.
  16. Make a program that reads 2 numbers and prints the smallest one.
  17. Make a program that reads 3 numbers and prints the smallest one.
  18. Make a program that reads 4 numbers and prints the smallest one. Use only 2 variables in your program.
  19. Make a program that reads 10 numbers and prints the smallest one. Use only 3 variables in your program.
  20. Make a program that reads 3 numbers and prints the 2 smallest numbers.
  21. Make a program that reads 4 numbers and prints the 2 smallest numbers. Use only 4 variables in your program.
  22. Make a program that reads 10 numbers and prints the 2 smallest numbers. Use only 4 variables in your program. Use a procedure to select the smallest numbers.
  23. Make a program that reads 2 numbers and prints the average of them.
  24. Make a program that reads 3 numbers and prints the average of them.
  25. Make a program that reads 10 numbers and prints the average of them. Use only 3 variables in your program.
  26. Make a program that reads 10 numbers and prints how many numbers greater than 100 were entered.
  27. Make a program that reads 10 numbers and prints how many numbers less than 17 were entered.
  28. Make a program that reads 10 numbers and prints how many numbers less than 17 and more than 100 were entered.
  29. Make a program equivalent to the last 3 exercises, that is, read 10 numbers and print how many numbers are greater than 100, how many numbers are less than 17 and how many numbers are less than 17 and greater than 100.
  30. Make a program that reads the time of day (just the hour, no minutes) and prints Good morning ou Good afternoon  ou Good night depending on the time of day.